Jump to content
  • Advertisement
Sign in to follow this  
EpicArtist

Projecting a 3d plane onto 2d space

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

How to? For example, I have a triangle in 3d space, what is the way to rotate this triangle so that all of its' points' z values are equal?

Share this post


Link to post
Share on other sites
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!