Class Leap::Unity::Geometry::Collision

class Leap.Unity.Geometry.Collision

Public Static Functions

static float DistanceTo (Rect rect, Sphere sphere)

Returns the distance between the closest points on the Rect and the Sphere, or 0 if the two overlap.

static float DistanceBetween (Sphere sphere, Rect rect)

Returns the distance between the closest points on the Rect and the Sphere, or 0 if the two overlap.

static bool Intersect (LocalPlane plane, LocalSegment3 line)

Returns true if the line segment intersects with the plane, or false otherwise.

Specify output parameters to receive more detailed information about the intersection, such as the point at which it occurs and whether the line lies on the plane.

static bool Intersect (LocalPlane plane, LocalSegment3 line, out Vector3 pointOnPlane, out float amountAlongSegment, out bool isLineCoplanar, bool intersectInfiniteLine = false)

Returns true if the line segment intersects with the plane, or false otherwise.

If intersectInfiniteLine is specified, returns true if the line defined by the line segment intersects with the plane, or false otherwise.

If this method returns true, no out parameters are set to NaN, and reasonable defaults are chosen in edge-cases (such as a coplanar line). If this method returns false, some or all output parameters may have no reasonable value and are set to NaN.

pointOnPlane is the point along the line defined by the segment that intersects with the plane. If the line segment is parallel to the plane and on the plane, pointOnPlane will be set to the center of the line segment as a convenience. Otherwise, it will be set to a Vector3 containing all NaNs.

amountAlongSegment is the normalized amount from A to B along the line segment that intersects with the plane. The line segment intersects with the plane only if this value is between 0 and 1 (inclusive). If the line segment is parallel to the plane and on the plane, amountAlongSegment will be set to 0.5f. Otherwise, amountAlongSegment will be set to NaN.

isLineCoplanar is true if the line defined by the line segment is wholly on the plane, or false otherwise.

static bool Intersect (LocalSegment2 seg1, LocalSegment2 seg2, out float t, out Vector2 p)

Returns whether seg1 and seg2 overlap. If they do, computes and outputs the intersection t value along seg1 and outputs the intersection point p. Otherwise, outputs default values.

static float Intersect (LocalSegment3 seg1, LocalSegment3 seg2, out float t1, out float t2, out Vector3 c1, out Vector3 c2)

Computes the squared distance between two 3D line segments, outputting the amount along each segment (0 to 1) corresponding to the closest points (t1 and t2), and outputting the closest points themselves (c1 and c2).

static bool Intersect2D (LocalSegment3 segment0, LocalSegment3 segment1, out Vector2 intersectionPoint, out float amountAlongSegment0, out float amountAlongSegment1)

Returns true if the two segments are not parallel or colinear and intersect in 2D, ignoring the segments’ Z components.

static float SqrDistPointSegment (LocalSegment3 segment, Vector3 p)

Returns the squared-distance of the point p from the segment.

static float SqrDistPointSegment (Vector3 a, Vector3 b, Vector3 c)

Returns the squared-distance of the point c from the segment defined by a, b.

static Vector3 ClosestPtPointSegment (LocalSegment3 segment, Vector3 p)

Returns the closest point to point p on the segment.

static Vector3 ClosestPtPointSegment (LocalSegment3 segment, Vector3 p, out float t)

Returns the closest point to point p on the segment. Also outputs the parameterization from 0 to 1 along ab that results in the closest point: closestPt(t) = a + t*(b - a).

static Vector3 ClosestPtPointSegment (Vector3 a, Vector3 b, Vector3 c, out float t)

Returns the closest point to point c on the segment ab. Also outputs the parameterization from 0 to 1 along ab that results in the closest point: closestPt(t) = a + t*(b - a).