Archived

This topic is now archived and is closed to further replies.

gimp

Distance between planes?

Recommended Posts

I have a flat plane. Above that plane is a polygonal mesh. I need to find out how high an arbitrary point on that mesh is above the flat plane. How would I go about solving this problem? I''m guessing that the first part would be to identify which exact polygon the point will be on, then perhaps using some math trick I don''t have calculate the andgles then from that derive the height? That brings up another question... How can I pick the triangle that the point is on? This doesn''t have to be fast, just simple. It''s for an offline calculation. Many thanks Chris

Share this post


Link to post
Share on other sites
This should help you with your original question: finding the distance between an arbitrary point and a plane.

Since you know everything about the first plane you know A, B, C, and D in the equation of a plane A*x + B*y + C*z = D where (x, y, z) is any point that lies on the plane. Note that the vector (A, B, C) is the normal of the plane. Now you simply have to plug in your original point into the plane equation and this gives you A*x1 + B*y1 + C*z1 = D1. If (A, B, C) was a unit vector (which it should be) then your answer is |D - D1|, otherwise it is this value divided by the magnitude of the vector (A, B, C).

I hope this is clear as actually computing this is quite easy, but I wanted to explain what I was doing instead of just giving you the final algorithm. I find the most important thing to remember when solving things using planes is that (A, B, C) is the plane''s normal vector.

Good luck.

Share this post


Link to post
Share on other sites
You say "an arbitrary point on that mesh". If you have the mesh''s transformation matrix, and the point is defined in object space, transform the point to world space and then work out the distance to the plane.

By a "flat plane" do you mean a horizontal one? Ie. where y (height) is constant. In that case, the distance is just (point.y - plane.y).

If the plane''s not horizontal, use Kyle''s algorithm above.

Dave

Share this post


Link to post
Share on other sites
Yep the horizontal plane is say 1,0,1 (thats flat isn''t it?)

I''m trying to build a (spell?) Delauney triangulator. In the first insertion you would have a square divided in to two trinagles.

Next I need to work out which point in the original bitmap deviates the most from the two triangle square. To calculate this accuratly I''ll need to work out the height of each point on the bitmap and compare that to mesh I''m inserting in to.

The equation I''m not sure about is working out how to compare the points from the bitmap to the planes that are in the constructed mesh.

So to work this out I need two things I''m not sure about.

1) How do I work out which polygon(and hence plane) a vertical vector pases through.

2) Once I know where that intersection on the place occurs, who do I find out it''s y value?


Kyle, keeping in mind I have VERY limited understanding of 3D math (which is proving a real hinderence).. I think I almost understand what your doing. I can barely even remember trig 10+ years ago in HS.

I''ll explain it the way I interpret your text, let me know if I''m right.

Your using a normal vector, or a vector that is perpendicular to the plane. Then your multiplying the vector by a point, I guess this gives your a location on that vector, which I guess you can extract a point from using trig.

What is |D - D1| though? It looks like D and D1 are both vectors. What do you get from subtracting the normal vector from the one we multiplied against the plane?

Again many thanks..

chris

Share this post


Link to post
Share on other sites