Minimum perpendicular vector between a point and a line

Okay, so I'm trying to find the algorithm of the separation axis theorem to work (for collision detection), and I need to find the minimum perpendicular vector between the point and the line. I do not ask for the minimum perpendicular distance (which I know how to find), but rather a vector that will have the same magnitude as this distance, and comes from an arbitrary point and a point on the line. I know the location of a point, a point on a line, and a unit vector indicating the direction of the line.

What I tried to do first found the minimum distance between a point and a line.

The next part is confusing, but I: 1) A vector is found between a point and a point on the line that I know 2) A vector is found between a point on the line and a point on the line plus a unit vector defining the direction of the line 3) Accepted the cross product of these two vectors (let's call this is a cross product A) 4) Accepted the cross product of the unit vector defining the direction of the line and the vector from the transverse product A (let's call it the transverse product B) 5) Normalized cross product B 6) Scaled transverse product B by m minimum distance

In any case, this whole attempt failed. Can someone tell me how should I find this vector?

+7
source share
2 answers

If I understand your question correctly, I believe that this is what you are looking for:

P - point D - direction of line (unit length) A - point in line X - base of the perpendicular line P /| / | / v A---X----->D (PA).D == |XA| X == A + ((PA).D)D Desired perpendicular: XP 

where the period is a point product and | XA | means value.

+24
source

enter image description here

From the above picture, you:

 q = p + s --> s = q - p = q - (p2-p1) = q + p1 - p2 ==> s^ = |q - p2 - p1| / |s| (unitary vector) Also: |s| = |q| sin c = |q|sin(ba) b = arcsin (qy / |q|); a = arcsin( p1y / |p1| ) where: |q| = (qx^2 + qy^2)^1/2 
+2
source

All Articles