### Projecting 3D Points to 2D Points

2

I know this is a common question and there are oodles of resources on the web and several questions here handling this area but I can't find exactly what I need. So, with apologies in advance, here goes:

I have a 3D point that needs to be converted to a 2D point

I have available:
Point location (Px,Py,Pz)
Camera location (Cx,Cy,Cz)
Camera orientation (I can control this but I don't know how to represent it)

I was trying to follow the wikipedia guide on this - http://en.wikipedia.org/wiki/3D_projection#Perspective_projection

My questions are:
How should I be representing the camera orientation?
How do I calculate the values of Ex,Ey,Ez from the wikipedia guide, the "viewer's position relative to the display surface"
Is there anything else I should know?

2012-04-04 01:02
by Recalcitrant Caprine

0

Old tutorials are great, mostly from the days before T&L and shaders, even before hardware rendering. Start with an understanding of them, i.e. /technical/math-and-physics/3d-matrix-math-demystified-r695">http://www.gamedev.net/page/resources//technical/math-and-physics/3d-matrix-math-demystified-r695 . Then go on to application for a camera: http://www.codeguru.com/cpp/misc/misc/graphics/article.php/c10123/Deriving-Projection-Matrices.htm

Basically, you translate and then rotate the entire 'universe' around the camera. So you have your point: you define a translation (movement) for the camera, then a rotation matrix. You apply them to any 'world content,' i.e. your point. You can then "cheat" and simply divide the x and y values by z to project to the 2d plane, but you should really do calculations that correct for field-of-view properly.

2012-04-04 01:14
by std''OrgnlDave
That first link seems to be broken, getting a 40 - Ben Baron 2012-04-04 01:24
It won't work in answer body. http://www.gamedev.net/page/resources/_/technical/math-and-physics/3d-matrix-math-demystified-r69 - std''OrgnlDave 2012-04-04 03:37

0

If you compile Opencv with Java bindings you can do this easily using the the [Calib3d module](http://docs.opencv.org/java/2.4.4/org/opencv/calib3d/Calib3d.html#projectPoints(org.opencv.core.MatOfPoint3f, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.MatOfDouble, org.opencv.core.MatOfPoint2f))

2017-05-11 05:31
by Yonatan Simson