0
\$\begingroup\$

So I sort of understand the math behind projecting 3d points onto a 2d plane. It's just some simple dividing and multiplication of distances. However I can't seem to wrap my head around projecting lines from 3d space onto a 2d plane.

Demonstration:

demo

Just to make this a little more simple, I'm going to be talking in terms of 2d projection onto a 1d line, because it's the same concept for 3d to 2d. So my issue is that if I want to project the line AB onto the viewing window which has a set focal length, I can just project both of the points of the line (A and B) onto the perspective line, and then draw the line between those two on the viewing window. However the difficulty comes when trying to project the line CD onto the line. The second point (D) of the line is behind the viewing window, and therefore cannot be projected onto the line. So how would one go about drawing line CD in the perspective window?

\$\endgroup\$
  • \$\begingroup\$ Look up "openGL projection matrix" there's a site "songho" or something that derives them \$\endgroup\$ – Alec Teal Jan 13 '15 at 11:45
1
\$\begingroup\$

If You subdivide the line into CE and ED and the projection of the 2 lines combined will be the projection of the full line.

Using that we split the line where it intersects the screen then EC' will be the resulting line and you ignore the ED part of the line.

Current day graphics pipelines will do this automatically using frustum culling with the near plane.

\$\endgroup\$

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.