distance_point_line_sqrd_xy

compas.geometry.distance_point_line_sqrd_xy(point, line)[source]

Compute the squared distance between a point and a line lying in the XY-plane.

Parameters
  • point ([float, float] or [float, float, float] | Point) – XY(Z) coordinates of a 2D or 3D point (Z will be ignored).

  • line ([point, point] | Line) – Line defined by two points.

Returns

float – The squared distance between the point and the line.

Notes

This implementation computes the orthogonal squared distance from a point P to a line defined by points A and B as twice the area of the triangle ABP divided by the length of AB 1.

References

1

Wikipedia. Distance from a point to a line. Available at: https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line.