Jump to content
  • Advertisement
Sign in to follow this  
brwarner

Convert 3D to 2D Points

This topic is 4447 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

Can someone give me the formulas to convert 3D points to 2D points in the simplist way possible please?

Share this post


Link to post
Share on other sites
Advertisement
Unless I don't understand what your asking the formula is point*view*projection where view and projection are matrixes that can be found here: view matrix, projection matrix

edit: note that point is x,y,z,w where w is typically 1.

Share this post


Link to post
Share on other sites
There are accessory functions to determine the conversion in most 3D APIs. For example you can use gluProject() and gluUnproject() to convert between world and screen coordinates with GL and Direct3D has D3DXVec3Unproject() and D3DXVec3Project().

Share this post


Link to post
Share on other sites
The standard method is to manually apply the pipeline to the points in question, which involves applying the world, view, projection, and viewport transforms, and perhaps performing a perspective divide.

However, the 'easiest way possible' would probably be to use someone else's code. If you're using OpenGL and have glu available, use gluProject(); I assume there's an equivalent in DX as well.

Share this post


Link to post
Share on other sites
What I was looking for was a trigonametric way to convert 3d to 2d using no API. I can not use an api because I am writing the program in Flash, so no DirectX or OpenGL.

Share this post


Link to post
Share on other sites
Quote:
Original post by brwarner
Can someone give me the formulas to convert 3D points to 2D points in the simplist way possible please?

You probably left out something important as the simplest way without any constraints is obvious:
2dpoint.x=0
2dpoint.y=0
is the simplest formula to convert 3d-points to 2d-points, it converts every 3d-point to (0,0). A bonus: it works for 4d-points too ;)

Share this post


Link to post
Share on other sites
It's ok I found this which seems to be simple enough:
http://chattyfig.figleaf.com/pipermail/flashcoders/2001-September/009906.html

Share this post


Link to post
Share on other sites
The simplest way if you have (x,y,z) is to let u=x/z, v=y/z, then rescale and translate (u,v) so that it fits on your screen in a nice way. All the projection matrix math you may have seen basically boils down to that.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!