Jump to content
  • Advertisement
Sign in to follow this  
DrainedBrain

Omitting the third coordinate of a 3d point on projection

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

i have a point P in space, and i want to project it on a plane which has the normal N, after getting the point D from the plane equation ax+by+cz = -D . i use the following equation [P = P - ( N dot P + D ) * N] to find the projected point coords. but, the point P has 3 coords. after projecting. so how can i algebraically calculate the point's actual x and y coordinates?

Share this post


Link to post
Share on other sites
Advertisement
There's not a simple answer to this as "the point's x and y coordinates" don't exist, or at least they aren't uniquely defined. You first need to choose your x and y axes, that is you need to work out how to map points in the plane to the 2D x-y plane.

The problem is that obvious ways of doing this don't always work. E.g you might choose to make one axis horizontal and the other perpendicular to it (along the slope of the plane). But this does not work when the plane is horizontal as there's more than one horizontal line in the plane.

but once you have your x and y you can use them to transform your 3D point to 2D. Write down unit vectors parallel to the x-axis, y-axis and the normal, and form a matrix with them as columns. This matrix lifts points from 2D into the plane, so the (trivial) inverse of this matrix transforms points fron the plane to 2D - more precisely the inverse generates points with the correct x-y cordinates and with a constant z that you can throw away/need not calculate.

Share this post


Link to post
Share on other sites
how will i get the x&y axis, and should i multiply the inverse vector to the point i got from the [P = P - ( N dot P + D ) * N] equation or to the original point ? can u please give me an example??

Share this post


Link to post
Share on other sites
It sounds like you are looking for something more than simply projecting a point onto a plane. In addition to the plane, you need an origin and an orientation of the X and Y axes. What it really boils down to is this: you have a coordinate system and you want project a point onto its XY plane.

To do that, you construct a 4x4 transformation matrix representing the coordinate system, transform the point, and then use the resulting X and Y values directly. Constructing the transformation matrix is the hard part and doing it requires the origin and orientation I mentioned earlier.

Share this post


Link to post
Share on other sites
If you're projecting a 3D point to a 2D plane, omit the component of the Normal with the largest value.

p(1,5,2)

n(9,7,3)

X is bigger, so project onto X-axis by removing it.
You now have:

p(5,2)
n(7,3)

Share this post


Link to post
Share on other sites
Quote:
Original post by DrainedBrain
how will i get the x&y axis, and should i multiply the inverse vector to the point i got from the [P = P - ( N dot P + D ) * N] equation or to the original point ? can u please give me an example??


Ok, the example I gave can be calcuated as follows. N must be a unit vector, '^' is the cross product.

Given N, to get a horizontal line prependicular to it caculate N ^ up-axis.
Normalise this to get a unit vector, call it X
Then calcuate Y = N ^ X
The vectors X and Y should be unit vectors, perpendicular to each other, and lie in the plane. You can them use these to form the matrix and inverse of it as described.

But this fails if the plane is horizontal - try doing it and N ^ up-axis is a zero vector and cannot be normalised. If this happens you need to choose X and Y by some other means, but as you know the plane is horizontal this is easily done - the horizontal coordinate axes for example.

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!