Public Group

# Distance from point to plane along a vector

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

## Recommended Posts

Hey, I'm looking for a way to find the distance from a point toa plane along a vector. I can get the distance from the point to the plane like so DotProduct(point,plane.Normal) +plane.Distance; but I'm not sure how to do it about a vector. This may explain what I want to do....
O < Point
|
|
|
_______________V_____________________________ < Plane

//
//This is the regular distance to plane, what I want is this
//

O < Point
/
/
/
/
_________|/__________________________________ < Plane

Any suggestions? Worst case scenario, I have to cast a ray into the plane. Is that practical for such an operation?

##### Share on other sites
Find the intersection between the plane and the line P + t*v and then calculate the distance between the two points.

EDIT: if the vector is of unit length than t is the distance you are searching. If it isn’t of unit length than the distance is t * length(v)

[Edited by - apatriarca on June 11, 2008 6:49:12 PM]

##### Share on other sites
So in other words, I'd need to cast a ray to find out the information? It seems as if it would be even simpler than that.

##### Share on other sites
Ray-Plane intersection isn’t a very expensive operation. I assume the plane is identified by the normal N and the distance D from the origin. To find the distance along the direction v from P to the plane (s in the following formula) you can use the following:

t = - (dot(N,P) + D) / dot(N,v)
s = t * length(v)

I don’t know if it’s possible to reduce the number of operations in some way.

EDIT: You haven’t to divide for the length but multiply by it.

[Edited by - apatriarca on June 11, 2008 6:09:44 PM]

##### Share on other sites
I guess it isn't very expensive : )! By the time I find a work around it'll more than likely have more work to it than that.

Thanks for the tip-off!

##### Share on other sites
Find the length of the projection of the unit vector, and scale accordingly (hint: similar triangles).

//
// Check a unit vector first
//

O
/|
1 / |
/ | determine this as per the "regular distance to plane
/ |
_________|/____|_____________________________ < Plane

O
/|
1 / | O <-- point
/ | A /|
/ | B/ | C
_________|/____|_____|/__|___________________ < Plane

1/A = B/C, therefore B (which is what you're looking for) = C/A.

You don't actually need to normalize the "reference" vector ahead of time, if it isn't already; you can factor its length into the calculation at the end instead. Of course you find that length simply by Pythagoras :)

Also, try the Math&Physics forum for this kind of stuff in general.

##### Share on other sites
Quote:
 Original post by ZahlmanFind the length of the projection of the unit vector, and scale accordingly (hint: similar triangles).*** Source Snippet Removed ***You don't actually need to normalize the "reference" vector ahead of time, if it isn't already; you can factor its length into the calculation at the end instead. Of course you find that length simply by Pythagoras :)Also, try the Math&Physics forum for this kind of stuff in general.

Doesn’t it produce practically the same code as mine?

C = dot(P,N) + D
A = dot(v,N)/length(v) // is there a faster way?

1. 1
2. 2
3. 3
Rutin
19
4. 4
khawk
14
5. 5

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633655
• Total Posts
3013187
×