Sign in to follow this  

Projecting a 3d plane onto 2d space

This topic is 3590 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

Setting all the z values to the planes z will basically project the triangle onto the plane, that’s not the same as rotating the triangle so it lies on the plane.

Its not clear exactly what you want to do from your post. If you want the triangle to lie on the plane and not be projected onto it you will have to do more than just set the z values.

There are a few ways you could do this but the first that comes to my mind is this.
Get the surface normal of the triangle.
Find the rotation between that and the planes normal.
Create a transform from that rotation and use it to transform the triangles vertices.
Now, with the triangle parallel to the plane you can set the z to the planes z.

Share this post


Link to post
Share on other sites
Basically, I'm looking for a method like Scythen's, olii's will not suit my purposes.
I need to just rotate the triangle so that all of the points contained inside the triangle have equal z values (not necessarily zero.) I don't really know how to execute transformations, however.

Share this post


Link to post
Share on other sites
I don't know your application (in which case there might be a better method to accomplish what you are trying to do) but here goes:

First, I'm going to refer to this article here:
http://pratt.siggraph.org/education/materials/HyperGraph/modeling/mod_tran/3drota.htm

That's 3d rotation equations (in a pretty simple to follow format) we'll need to accomplish this 'feat'.

First, let's start with the understanding that any rotation about any axis has a special feature: a point laying on that axis will not be rotated! So if we rotate about the x-axis, the x-coordinate remains unchanged (look at the rotation sheet).

First step is to shift the entire triangle to make the z-coordinate on one vertex to be zero. only shift along the z, and however much you shift by, shift all the other z-coordinates on the verticies by the same amount.

Now, we'll walk the other two verticies to the X-Y plane: Create an arbitrary axis through the first point (now sitting at z=0) and one of the other two points.

Around that axis that runs through those two points, rotate the 3rd point until it's z is zero.

Now, make an axis through the first point, the second point (which is now at z = 0) and rotate the other point until its Z is at zero.

That's it!

Now, If you are trying to do something that you see in a lot of games or modeling packages, then you need to describe that, because this technique isn't really used anywhere, and a solution to your problem might exist elsewhere.

Share this post


Link to post
Share on other sites
Here's an idea : project your triangle onto the 2D surface of it's own plane. Take one side of the triangle say point 1 minus point 2, normalize it and call that X. Then take the cross product of X with the plane's normal and call that Y. Then take each point of the triangle and create a new point by projecting that point onto X to get the x component and onto Y you get the y component. What you'll end up with is a 2d triangle that has the same edge lengths as your original triangle, and no z coordinates. Is there some other property besides that that you need? I can't be much more help without knowing why you're trying to do this.

Share this post


Link to post
Share on other sites
@Alrecenk, Are you sure that would work?

@NatasDM, that method seems ominously remniscent of "guess and check" to me.

@Sythen, are you sure that would work even with the problems of Euler angle gimbal lock?

My application for this is to perform x and y comparisons within the triangle. For example, comparing a point inside of the triangle to the vertices of the triangle. It would be much easier in 2d. Specifically UV mapping. The texture should center at the location of the dynamic point within the triangle.

Share this post


Link to post
Share on other sites
Lol, Nope, no guess-and-check. Simply set Z' as zero and solve for the angle, then use that angle to find the other coordinates.

Actually, from a coding perspective, I like Alrecenk's Idea. Basically, one of the sides of the triangle would line up with the X axis. In fact, one vertex would be one the origin. That leaves only one vertex 'floating' some where in 2d space.

Basically, Alrecenk has you reconstructing the triangle. You'd see what it looks like, but it's orientation would be all messed up (as would my approach really).


Perhaps you should instead try transforming the Picking ray into the Space of the triangle. Then you can set the z value of the ray as zero and it would give you your center.

Share this post


Link to post
Share on other sites

This topic is 3590 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