closestPointToPoint method

Vector3 closestPointToPoint(
  1. Vector3 point,
  2. bool clampToLine,
  3. Vector3 target
)

point - return the closest point on the line to this point.

clampToLine - whether to clamp the returned value to the line segment.

target — the result will be copied into this Vector3.

Returns the closets point on the line. If clampToLine is true, then the returned value will be clamped to the line segment.

Implementation

Vector3 closestPointToPoint(Vector3 point, bool clampToLine, Vector3 target) {
  final t = closestPointToPointParameter(point, clampToLine);

  return delta(target).scale(t).add(start);
}