# Find the point on a line that is X distance away from a plane

1. Jun 1, 2014

### caibbor

given:
a plane with normal N and a point on the plane P.
a line from A to B that intersects the plane but is not coplanar.

Find the point C on the line that is X distance away from the plane (along the plane's normal, meaning the shortest line that can be drawn from the point to the plane)

Note: I am not mathematically savvy, I prefer to work visually with vectors, cross products, dot products, etc, such as equations like the distance D of point B to the plane is D = N dot ( B - P ). That makes sense to me, numbers and fancy equations... not so much.

Last edited: Jun 1, 2014
2. Jun 1, 2014

### Matterwave

Do you have any thoughts on how to approach this problem? This sounds like a homework problem, so before we can help, you need to tell us how you've worked on this problem.

3. Jun 1, 2014

### caibbor

It's not homework, it's for a game engine. It's part of an attempt to move a swept sphere relatively close to a plane along the swept sphere's velocity vector without intersecting the plane.

out of the sweep algorithm, I get the origin of the sphere where it will first collide with the plane. Currently I'm just moving it an extra epsilon away from the poly along the direction of the velocity vector, but the less steep the angle of that vector to the plane, the closer that point actually is to the plane. So, you see, I need to move it the same distance away from the plane regardless of the angle of the vector, and the point needs to stay on the velocity vector. (if I don't stay on the vector, I risk colliding with another polygon somewhere. I know that anything before a certain point on that vector is safe, since the poly is the closest thing I have collided with)

I have examined the equation mentioned above to get the distance of a point to a plane, D = N dot (B - P ), where D is the only unknown. I figure that you could re-arrange this equation such that D is a known (the distance we want to set the point at) and make P the unknown, that would work. But I don't believe it is possible to reverse dot product. you can't take a vector, turn it into a scalar, and then back to a vector since it can have many possible answers. It would be something like P = B + ( N revrese_dot ( D ) )

edit: I'm currently reseraching whether "reverse dot product" is a thing. I have found this link: https://www.physicsforums.com/showthread.php?t=668149

Last edited: Jun 1, 2014
4. Jun 1, 2014

### Matterwave

Ok, looking at your first post. Do you want the distance to be along the line, or just the length of the shortest straight line it is possible to draw from the point C to the plane?

5. Jun 1, 2014

### caibbor

the latter.

the distance of the shortest line drawn from a point to the plane (that is to say, the distance along the plane's normal, not the line) but the point needs to exist on the line.

Last edited: Jun 1, 2014
6. Jun 1, 2014

### Matterwave

Well, it seems first we have to find the point Q of the intersection between the line and the plane. We can then project the point C perpendicularly onto the plane to find a point T. since we know where the intersection is, we can find the distance from C to the intersection point: ||C-Q||. We can also find the distance from the projected point to the intersected point: ||T-Q||. These two lines plus the straight line down from point C to T define a right triangle, and the distance from the point C to the plane is then: D=||C-T||=\sqrt(||C-Q||^2-||T-Q||^2)

So the problem is to find the point Q given A, B, P, and N. And then finding the point T given some arbitrary C that is on the line AB.

I think though that this procedure will not be unique, and will yield potentially two points on the line which both are a distance x away from the plane.

This problem will obviously also have no solutions if the line is perpendicular to the plane (or co-planar).

7. Jun 1, 2014

### caibbor

Thank you, I'm going to digest this a little bit and get back to you.