Click or drag to resize

UtilIntersectLineSphere(Vector3, Vector3, Vector3, Double) Method

Intersect a line with a sphere (using 10^-6 as a tolerance in equality).

Namespace: Demo3D.Common
Assembly: Demo3D.Common (in Demo3D.Common.dll) Version: 19.01.00
Syntax
C#
public static Vector3[] IntersectLineSphere(
	Vector3 A,
	Vector3 B,
	Vector3 sphereCenter,
	double sphereRadius
)

Parameters

A  Vector3
First point on line.
B  Vector3
Second point on line.
sphereCenter  Vector3
Center of the sphere.
sphereRadius  Double
Radius of the sphere.

Return Value

Vector3
null meaning no intersections, or a Vector3[], containing the two intersections, or just a single intersection if the line and sphere are just touching.
See Also