|
-
May 13th, 2001, 10:28 AM
#1
Hard Math Problem!
I have a small universe, with the 3 standard dimensions: X,Y and Z.
Given these things:
- The (x,y,z) coordinates of the "camera"
- the direction that the camera is pointing
- the (x,y,z) coordinate of a point in space
Can someone tell me the maths expression that will resolve this info into an (x,y) coordinate, so I can plot it on a picturebox.
My brain is aching, please help!
-
May 13th, 2001, 10:33 AM
#2
Frenzied Member
You need to use some linear algebra for this kind of thing, what you're basically looking for is a projection matrix (I think that's what it's called). I don't know too much about it myself but there are a lot of articles on this kind of translation at www.gamedev.net , since it's the sort of thing that 3D games use a lot of. www.flipcode.com has some good maths resources for this sort of stuff too.
Harry.
"From one thing, know ten thousand things."
-
May 13th, 2001, 06:15 PM
#3
What are you programming this in? GDI, OGL, D3D, Other? If its D3D8, there is a function in the D3DX library called D3DXVec3Project(...) that will do what you want. OGL has a similar function, although i dont know what its called. Search for "Project". If its GDI, you are going to have some fun playing with vector calculus.
Z.
-
May 14th, 2001, 12:10 PM
#4
Oh dear, I knew someone would ask me that. I'm using PocketC on the PalmOS platform! All I have to work with are the standard math expressions: Cos() Atn() etc...
Its a black/white LCD display on my Palm IIIx handheld, so I'm looking for simple solutions really.
-
May 14th, 2001, 01:10 PM
#5
Monday Morning Lunatic
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 8th, 2001, 08:12 AM
#6
New Member
Depends if the camera is always upright, or whether it rolls as well.
The maths for a rolling camera is well tricky, but I can give you the bits for upright no sweat.
Assuming x for horizontal, y for vertical & z for lateral,
Using X,Y for final screen,
x1,y1,z1 for camera pos,
x2,y2,z2 for object pos,
and ang for camera angle
X = (x2 - x1) * Cos(ang) + (z2 - z1) * Sin(ang)
Y = (y2 - y1)
This assumes no perpective
With perspective,
Z = (x2 -x2) * Cos(ang) + (z2 - z1) * Sin(ang)
X = ((x2 - x1) * Cos(ang) + (z2 - z1) * Sin(ang)) * Log(Z)
Y = (y2 - y1) * Log(Z)
This is in maths speak and not code, gotta leave some work for you to do
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|