[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Distance between point and a line passing through other two points

On 07-02-18 12:06, Dhananjay wrote:
> Hello all,
> ...
> I want to write a script that can calculate shortest distance d between
> point (x0,y0,z0) and the line((x1,y1,z1), (x2,y2,z2)).
> In other words,
> d = distance(a, line(b,c))
> Since I have information of the coordinates of these points only, I am not
> sure how to put it into python script to get distance d.
> On searching Internet, some solutions are discussed for 2D coordinates
> (i.e. for (x0,y0), (x1,y1) and (x2,y2) ).
> However, I need solution for 3D coordinates.

Look at the vector solutions: https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line#Vector_formulation