Get points of a 3d triangle relative to its own plane in 2d

Started by
1 comment, last by CGameProgrammer 12 years, 5 months ago
I need to convert a 3d triangle into a 2d triangle, as if it had been rotated so that all points lied on the same z and then ortho projected.

How can I do this?

(Code examples would be very helpful)
Advertisement
Matrix planeMatrix = makeLookAtMatrix( triangleCenter /*eyePos*/, triangleCenter + triNormal /*aim point*/, pickASensibleUpVector /*make sure it isn't parallel to the aim direction*/ );
planeMatrix = invert(planeMatrix);


now transform the triangle with it..... (You may want to be more careful with the positioning of the origin in your new coordinate frame though....)
It's easiest to arbitrarily declare one of the triangle's sides as being parallel to the X or Y axis. So if you have a triangle and say its first side is 4 units long. You can just start by saying its two endpoints are at {0,0} and at {4,0}. Then you just have to calculate the position of the remaining point. You know the lengths of the other two sides; it's exactly same in 3D as in 2D since the triangle lies along a plane, and you can easily find equations online for finding the point given that you know all lengths (and all angles, as a result).
~CGameProgrammer( );Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.

This topic is closed to new replies.

Advertisement