Click or drag to resize

UtilCalculateLineLineIntersection(Vector3, Vector3, Vector3, Vector3) Method

Calculates the intersection line segment between 2 lines (not segments).

Namespace: Demo3D.Common
Assembly: Demo3D.Common (in Demo3D.Common.dll) Version: 19.01.00
Syntax
C#
public static Vector3[] CalculateLineLineIntersection(
	Vector3 line1Point1,
	Vector3 line1Point2,
	Vector3 line2Point1,
	Vector3 line2Point2
)

Parameters

line1Point1  Vector3
Start of the first line.
line1Point2  Vector3
End of the first line.
line2Point1  Vector3
Start of the second line.
line2Point2  Vector3
End of the second line.

Return Value

Vector3
Returns null if no solution is found (lines are parallel or co-incident), or a Vector3[] containing the start and end point of the intersection segment; noting that if the lines actually do intersect, these two values will be the same.
Remarks
It returns a line segment, because in general, two 3D lines will not actually intersect, but there is a line segment which joins the two lines at the point where the distance between them is minimised.
See Also