Jump to content
  • Advertisement
Sign in to follow this  
ido098

3d point - perspective projection

This topic is 2510 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi..
I wrote an equation to calculate a 3d point's projection
98% of the time this equation works, but it's crucial that it will work 100% of the time.
here's what I got:
first we define some vars.
eye -> 3D point for our point of view of the scene
point -> 3D point that we want to project on the screen
p2d -> our point after projection
I assume that on screen, Z = 0, therefore:
0 = point.z + u * (eye.z - point.z)
u = -point.z / ( eye.z - point.z )
p2d.x = point.x + u * (eye.x - point.x)
p2d.y = point.y + u * (eye.y - point.y)


this is an image when it's ok:
http://postimage.org/image/bss2e9gcl/
this is an image when it's bad:
http://postimage.org/image/t4sezp9tx/

just to make sure you see it, in the "bad" picture, you can see that one corner of the table moves to a different place
which makes the table look bad...

any idea why this happens?

also, is there another way of doing this without changing my axes?

Share this post


Link to post
Share on other sites
Advertisement
See here for a derivation of the perspective projection formulas.

I tried to read your derivation, but could not understand it very well. One thing I noted is that u = -point.z / ( eye.z - point.z ) can cause a division by zero, and that you don't seem to be using the concepts of a near plane and an eye (observer) point (or they are somehow hidden implicitly in your derivation).

Share this post


Link to post
Share on other sites
what I did is a 3D-Line equation (and I split it into x,y,z )

(x, y, z) = point + t * ( eye - point )
to solve the equation I decided that Z=0 (since Z=0 on screen)

btw thanks for the link, I think I'll manage from here

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!