Minimum perpendicular Distance of a point to a line in 3D plane algorithm

How to find the minimum perpendicular distance of point from a line in 3D plane?

Please give me the logic and I will try to code on myself.

Please let me know how to do it in terms of x,y,z that is in terms of coordinate systems.

I am finding it a bit difficult to find the right solution which will be easy from a coding point of view. Online solutions are little bit rusty to understand. So please help me.

Please note line is given in terms of 3D space equation.


Given point A and a line, pick two different points on the line (B and C). Calculate the area of the triangle ABC with use of Heron's formula. Multiply the area by 2 and divide it by length of [BC]. You have the result you needed.


For an infinite line, the minimum distance is the length of line segment at right-angles to the infinite line passing through the point starting at the line and ending at the point. The direction of the perpendicular is given by the cross product of the unit normal to the plane and the unit vector along the line, the foot of the perpendicular is given by simultaneous solution of the equation for the first line, and for the perpendicular through the point. The distance between the points is what you are after.

For a finite line, this is a solution only if the foot of the perpendicular is on the segment; otherwise it's the shorter of the distance between the point and either end of the segment.


You say the line is given as an equation in 3D, but really planes are given by equations. And since the line is said to be lying in a 3D plane, presumably given by another equation, the line is actually the intersection of two planes.

To get the direction vector of the line, take the cross product of the normals to the two planes. If you use Pavel's method, you don't need this.

To get a point on the line, pick some value for x, say x = 0. Then solve the two equations for y and z after plugging in that value. To find another point to use in Pavel's method, set x to some other value, say x = 1, and solve the system again.

If the line is oriented the wrong way (perpendicular to the x axis), x may be a fixed value. In that case, try setting y to two fixed values. If that still doesn't work, try z. Also, check that the original planes are not parallel, so that there actually is a line of intersection.

To solve the question without Pavel's method, cross the direction of the line with the vector formed by the given point and a point you found on the line. Now cross that result with the line direction to get a new vector. Dot that vector with the original point and again with a point on the line. Take the difference, and divide by the length of the vector.

链接地址: http://www.djcxy.com/p/84924.html

上一篇: 用于GPS坐标的数学函数

下一篇: 3D平面算法中点与线的最小垂直距离