def closest_point_on_line(point, line): """Computes closest point on line to a given point. Parameters ---------- point : sequence of float XYZ coordinates. line : tuple Two points defining the line. Returns ------- list XYZ coordinates of closest point. Examples -------- >>> See Also -------- :func:`basic.transformations.project_point_line` """ a, b = line ab = subtract_vectors(b, a) ap = subtract_vectors(point, a) c = vector_component(ap, ab) return add_vectors(a, c)
def closest_point_on_line(point, line): """Computes closest point on line to a given point. Parameters ---------- point : [float, float, float] | :class:`compas.geometry.Point` XYZ coordinates. line : [point, point] | :class:`compas.geometry.Line` Two points defining the line. Returns ------- [float, float, float] XYZ coordinates of closest point. Examples -------- >>> See Also -------- :func:`basic.transformations.project_point_line` """ a, b = line ab = subtract_vectors(b, a) ap = subtract_vectors(point, a) c = vector_component(ap, ab) return add_vectors(a, c)