I have 3D points and I need to make an 2D orthographic projection of them onto a plane that is defined by the origin and a normal n. The meaning of this is basically looking at the points from the top (given the vertical vector). How can I do it?

What I'm thinking is:

  1. project point P onto the 3D plane: P - P dot n * n
  2. look at the 3D plane from the "back" in respect to the normal (not sure how to define this)
  3. do an ortho projection using max-min coordinates of the points in the plane to define the clipping

I am working with iOS.


If you're working to build a 3D viewport you probably want a projection matrix. Which means in addition to your normal n you also need to define an "up" vector in the plane. That is, if the plane represents the screen of the iPhone, you need a vector that shows which direction the top of the iPhone is.

Then, your n vector crossesd with your up vector will give you a third vector, orthogonal (at right angles) to the first two. (Also, your n vector should be orthogonal to the up vector, but that should happen automatically if the up vector is already in the plane).

Once you have your three vectors, normalize them, and put them as the columns in a 3x3 matrix. If you want the x and y coordinates to be in the plane, with the z coordinate being the distance from the plane, put the crossed vector you calculated as your first column, the up vector as the 2nd column, and n as the third.

Then you simply multiply your point P by your matrix M to get a new point P' (that is, P * M = . P'. Or if you want to think of the points as column vectors, do M^T P = P'). P'.x,y will be in the plane, and P'.z will be the distance from the plane, which you can drop if you're projecting on to the plane.

Note that this doesn't do anything around scale or translation of the points, or clipping things to the viewport. If you want all of that you probably want a full fledged Model-World-Camera-View-Projection-Clip transformation pipeline, and it gets more involved. It's an old book but the Cg Tutorial had a good section explaining the basic transformation flow.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.