# Projecting Polygons to 2D plane and back to 3D

This topic is 3283 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey, I want to clip two faces (polygons) of two Boxes (not axis aligned) with eatch other. The two polygons have the same normal, so they are parallel and they are on the same plane (the distance between them is 0). Since I know how to clip 2D-Polygons, I want to have 2D-Coordinates instead of 3D (since they share the same normal and are on one plane already, I want to use that plane as the "2D-World"...). After clipping, I want to convert them back to 3D-Coordinates. Does anybody know how to do that? Thanks a lot, D.

##### Share on other sites
If you take any two unique points on the plane (from the polygons for instance), you can create a vector on the plane -- call it 'U'. Given normal 'N', you can do NxV and get a third vector 'V'. Once you normalize 'U' and 'V' (assuming 'N' is already normalized), you then have all you need to generate a transformation matrix that will give you 2D coordinates. Take a 3x3 matrix 'M' and plug 'U', 'V', and 'N', into each of the three rows, respectively. Transform all points 'P' from all polygons using M·P. From there on out you can perform the 2D clipping by simply ignoring the Z-component of the transformed points. When you're done, you transform all points back using MT·P. They should all have the same Z-value they had after you performed the first transformation because you've been ignoring it.

##### Share on other sites
Hey,

thank you for the fast answer! :)

Quote:
 Original post by ZipsterThey should all have the same Z-value they had after you performed the first transformation because you've been ignoring it.

But during the clipping process there will be new points created. How do I find their Z-Values? Or am I getting something wrong?

##### Share on other sites
Quote:
Original post by Donner
Quote:
 Original post by ZipsterThey should all have the same Z-value they had after you performed the first transformation because you've been ignoring it.

But during the clipping process there will be new points created. How do I find their Z-Values? Or am I getting something wrong?

All the transformed points from the original polygons will have the same Z-value because they're on the same plane, so for all new points just plug in that Z-value to put them on the plane.

##### Share on other sites
And it doesn't matter what I chose the Vector 'U' to be as long as it is on the plane? (So the Vector from Point A to Point B, if both points are on the plane, right?)

And one more question about the matrix: Will it be one Row for eacht Vector (saying U goes in the first, V in the second and N in the third row?) Or is it that the X-Xomponents of the three vectors go in the 1st row, the Y-Components in the second etc.?

Thank you so much!

##### Share on other sites
Quote:
 Original post by DonnerAnd it doesn't matter what I chose the Vector 'U' to be as long as it is on the plane? (So the Vector from Point A to Point B, if both points are on the plane, right?)

That's correct, it can be anything on the plane.

Quote:
 And one more question about the matrix: Will it be one Row for eacht Vector (saying U goes in the first, V in the second and N in the third row?) Or is it that the X-Xomponents of the three vectors go in the 1st row, the Y-Components in the second etc.?

One row for each vector, so:

| U.x U.y U.z |
| V.x V.y V.z |
| N.x N.y N.z |

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633768
• Total Posts
3013743
×