distanceSqToSegment

fun distanceSqToSegment(v0: Vector3, v1: Vector3, optionalPointOnRay: Vector3? = null, optionalPointOnSegment: Vector3? = null): Double

Returns the squared distance between this ray and the line segment [v0, v1].

When provided, optionalPointOnRay receives the point on this ray closest to the segment, and optionalPointOnSegment receives the point on the segment closest to this ray.

Return

The squared distance.

Parameters

v0

The start point of the line segment.

v1

The end point of the line segment.