# Align Polygon with Plane

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

## Recommended Posts

What I'm trying to do is align my polygon with the plane that would intersect the x and y axis -- or in other words figure out the 2D triangle version of a 3d triangle. I know how to get the lengths of the vectors, but that's as far as I can get. Any idea how I might do this? Any ideas are welcome! :)

##### Share on other sites
In this particular case, it's very easy -- just set the Z value to 0. That's the orthogonal projection of the triangle to the X/Y plane. If you want some other kind of projection, you have to first multiply with that matrix, and then project.

To project on an arbitrary plane, you make sure that the distance between the vertex and the plane is 0, for each vertex. To do this, if you have a plane normal P.N and a plane distance from origin P.d, do something like:

  planeVertex = vertex + P.N * (P.d - dot(vertex, P.N));

##### Share on other sites
Thanks. :) Actually I just began to try this and realized that that does in fact do what I asked, but I didn't quite ask the question right. The trick is, I need to maintain the same distance and angle between vertices.
In other words, it's like if I had a triangle and rotated it so it was facing the user, except I have no idea how I'd know what xyz angles to use. Instead of rotating it, one idea I had was to get the vector lengths and angles between vectors that make up the triangle.
Any and all advice are welcome! :)

##### Share on other sites
Quote:
 Original post by renman29Thanks. :) Actually I just began to try this and realized that that does in fact do what I asked, but I didn't quite ask the question right. The trick is, I need to maintain the same distance and angle between vertices. In other words, it's like if I had a triangle and rotated it so it was facing the user, except I have no idea how I'd know what xyz angles to use. Instead of rotating it, one idea I had was to get the vector lengths and angles between vectors that make up the triangle.Any and all advice are welcome! :)
There are a few ways you could adjust the orientation of the triangle so that it is parallel to the plane. Here's one:

1. Compute an axis-angle rotation that rotates the triangle normal onto the plane normal. The axis and angle of the 'shortest' such rotation can be computed from the cross product of the two normals.

2. Rotate the triangle about some point (such as the average of the vertices) using the rotation computed in step 1.

However, with some more info about what you're trying to do it would be easier to recommend a specific solution.

##### Share on other sites
Yep, that works perfectly! Thanks! :D

1. 1
Rutin
47
2. 2
3. 3
4. 4
5. 5

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632993
• Total Posts
3009765
• ### Who's Online (See full list)

There are no registered users currently online

×