magnet.geometric_utils.closest_to_segment#

magnet.geometric_utils.closest_to_segment(x1: ndarray, x2: ndarray, p: ndarray) ndarray#

Compute the point of a segment closest to 1a given point.

Computes the the point of the segment of extremes x1, x2 that is closest to the point p.

Parameters:
  • x1 (np.ndarray of float) – Coordinates of the extremes of the segment.

  • x2 (np.ndarray of float) – Coordinates of the extremes of the segment.

  • p (np.ndarray of float) – Coordinates of the point of interest.

Returns:

The coordinates of the point closest to p.

Return type:

np.ndarray of float