Convert 3D to 2D Points

Started by
8 comments, last by yellowjon 17 years, 9 months ago
Can someone give me the formulas to convert 3D points to 2D points in the simplist way possible please?
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.
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().
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.
Orthographic projection
Perspective projection

EDIT Oh yeah:
Isometric projection
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.
Quote:Original post by StormArmageddon
view matrix, projection matrix


If you look around on these pages I supplied you can find how to do it without api using linear algebra. Here is a link on the view transform page LookAtLH.
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 ;)
It's ok I found this which seems to be simple enough:
http://chattyfig.figleaf.com/pipermail/flashcoders/2001-September/009906.html
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.

This topic is closed to new replies.

Advertisement