Sign in to follow this  

Align Polygon with Plane

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by renman29
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! :)
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 this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this