Intersection Helper  1.0
Library of helper functions to test intersections between 3D shapes
Static Public Member Functions | List of all members
IntersectionHelper Class Reference

Class of static functions to help with intersection calculations More...

Static Public Member Functions

static float DistanceLineLine (Vector3 lineAPoint, Vector3 lineADirection, Vector3 lineBPoint, Vector3 lineBDirection)
 Gets the shortest distance between two infinite lines. More...
 
static float SqrDistanceSegmentToSegment (Vector3 segment0Point0, Vector3 segment0Point1, Vector3 segment1Point0, Vector3 segment1Point1, out float closestPoint0, out float closestPoint1)
 Gets the square of shortest distance between two finite line segments. More...
 
static float SqrDistancePointTriangle (Vector3 point, Vector3 triangle0, Vector3 triangle1, Vector3 triangle2, out Vector3 closestPoint)
 Gets the square of shortest distance between a point and a triangle in 3D space. More...
 
static bool IsPointInTriangle (Vector3 p0, Vector3 p1, Vector3 p2, Vector3 point)
 Checks if a point lies inside a triangle More...
 
static bool GetPlaneFromTriangle (Vector3 t0, Vector3 t1, Vector3 t2, out Vector3 outPlanePoint, out Vector3 outPlaneNormal)
 Gets a point and normal direction representing the plane containing a given triangle. More...
 
static Vector3 PointSegmentProjection (Vector3 point, Vector3 segPoint0, Vector3 segPoint1)
 Gets the projection of a point on a finite line segment. More...
 
static bool ClosestPointsLineToLine (Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, out Vector3 pa, out Vector3 pb)
 Gets the closest point between two infinite lines. More...
 
static bool IntersectAABBoxWithOOBBox (Vector3 minA, Vector3 maxA, Matrix4x4 matrixB, Vector3 minB, Vector3 maxB)
 Determines if an AABB box intersects with an OOBB box. More...
 
static bool IntersectCapsuleWithCapsule (Vector3 capsule0Point0, Vector3 capsule0Point1, float capsule0Radius, Vector3 capsule1Point0, Vector3 capsule1Point1, float capsule1Radius)
 Determines if a capsule intersects with another capsule More...
 
static bool IntersectCapsuleWithCapsule (Vector3 capsule0Point0, Vector3 capsule0Point1, float capsule0Radius, Vector3 capsule1Point0, Vector3 capsule1Point1, float capsule1Radius, out Vector3 collisionPointOnCapsule1, out Vector3 pushBackVector)
 Determines if a capsule intersects with another capsule, returning the intersection point on the outer surface of capsule1 and the pushback vector to separate capsule1 away from capsule0 More...
 
static bool IntersectInfinitePlaneWithInfinitePlane (Vector3 planeNormal0, Vector3 planePoint0, Vector3 planeNormal1, Vector3 planePoint1, out Vector3 linePoint, out Vector3 lineDirection)
 Determines if two planes intersect. If yes, it also returns the line that intersects the two planes. More...
 
static bool IntersectLineWithInfinitePlane (Vector3 linePoint, Vector3 lineDir, Vector3 planePoint, Vector3 planeDir, out Vector3 intersectionPoint)
 Determines if a line intersects with a plane, and if yes, also returns the intersection point. More...
 
static bool IntersectLineWithTriangle (Vector3 linePoint, Vector3 lineDir, Vector3 t0, Vector3 t1, Vector3 t2, out Vector3 outContact)
 Determines if a infinite line intersects with a triangle, and if yes, also returns the intersection point. More...
 
static bool IntersectLineWithLine (Vector3 line0Point, Vector3 line0Vec, Vector3 line1Point, Vector3 line1Vec, out Vector3 intersectionPoint)
 Determines if two infinite lines intersect each other More...
 
static int IntersectLineWithCapsule (Vector3 pointOnLine, Vector3 lineDirection, Vector3 capsuleOrigin, Vector3 capsuleDirection, float capsuleRadius, out float[] afT)
 Determines if an infinite line intersects a capsule More...
 
static bool IntersectOOBBoxWithOOBBox (Matrix4x4 matrixA, Vector3 minA, Vector3 maxA, Matrix4x4 matrixB, Vector3 minB, Vector3 maxB)
 Determines if an OOBB box intersects another OOBB box More...
 
static bool IntersectPointWithAABBox (Vector3 point, Vector3 minA, Vector3 maxA)
 Determines if a point lies inside an AABB box More...
 
static bool IntersectPointWithOOBBox (Vector3 point, Matrix4x4 matrix, Vector3 min, Vector3 max)
 Determines if a point lies inside an OOBB box More...
 
static bool IntersectPointWithSphere (Vector3 point, Vector3 center, float radius)
 Determines if a point lies inside a sphere More...
 
static bool IntersectPointWithCapsule (Vector3 point, Vector3 capsulePoint0, Vector3 capsulePoint1, float capsuleRadius)
 Determines if a point lies inside a capsule More...
 
static bool IntersectPointWithTube (Vector3 point, Vector3 tubeStart, Vector3 tubeEnd, float radiusStart, float radiusEnd)
 Determines if a point lies inside a tube More...
 
static bool IntersectRayAABBox (Vector3 originRay, Vector3 dirRay, Vector3 minBox, Vector3 maxBox, out Vector3 coord)
 Determines if a ray starting from a given point intersects with an AABB box More...
 
static bool IntersectRayOOBBox (Vector3 originRay, Vector3 dirRay, Matrix4x4 matrixBox, Vector3 minBox, Vector3 maxBox, out Vector3 coord)
 Determines if a ray starting from a given point intersects with an OOBB box More...
 
static bool IntersectRayWithCylinder (Vector3 rayOrigin, Vector3 ray, Vector3 cylinderBasis, Vector3 cylinderAxis, float radius, float height, out float dist, out Vector3 hitPoint, out float distOnCylinder)
 Determines if a ray starting from a given point intersects with a cylinder More...
 
static int IntersectSegmentWithCapsule (Vector3 segmentPoint, Vector3 segmentDirection, Vector3 capsuleOrigin, Vector3 capsuleDirection, float capsuleRadius, out Vector3[] intersectionPoints)
 Determines if a finite segment intersects with a capsule More...
 
static bool IntersectSegmentWithCapsule (Vector3 segmentPoint0, Vector3 segmentPoint1, Vector3 capsulePoint0, Vector3 capsulePoint1, float capsuleRadius)
 Determines if a finite segment intersects with a capsule More...
 
static bool IntersectSegmentWithInfinitePlane (Vector3 p0, Vector3 p1, Vector3 planeOrigin, Vector3 planeNormal, out Vector3 outContact)
 Determines if a finite segment intersects with a plane More...
 
static bool IntersectSegmentWithSegment (Vector3 segAPoint0, Vector3 segAPoint1, Vector3 segBPoint0, Vector3 segBPoint1, out Vector3 intersectionPoint, out float sFactor, out float tFactor)
 Determines if two finite segments intersect More...
 
static bool IntersectSegmentWithTriangle (Vector3 p0, Vector3 p1, Vector3 t0, Vector3 t1, Vector3 t2, out Vector3 outContact)
 Determines if a finite segment intersects with a triangle More...
 
static bool IntersectSegmentAABBox (Vector3 point0Seg, Vector3 point1Seg, Vector3 minBox, Vector3 maxBox, out Vector3 coord0, out Vector3 coord1)
 Determines if a finite segment intersects an AABB box More...
 
static bool IntersectSegmentWithOOBBox (Vector3 segPoint0, Vector3 segPoint1, Matrix4x4 boxMatrix, Vector3 boxMin, Vector3 boxMax)
 Determines if a finite segment intersects with an OOBB box More...
 
static bool IntersectSegmentWithOOBBox (Vector3 point0Seg, Vector3 point1Seg, Matrix4x4 matrixBox, Vector3 minBox, Vector3 maxBox, out Vector3 coord0, out Vector3 coord1)
 Determines if a finite segment intersects with an OOBB box, returning the intersection points More...
 
static bool IntersectSegmentWithSphere (Vector3 segPoint0, Vector3 segPoint1, Vector3 sphereCenter, float sphereRadius)
 Determines if a finite segment intersects a sphere More...
 
static bool IntersectSphereWithAABBox (Vector3 center, float radius, Vector3 min, Vector3 max)
 Determines if a sphere intersects with an AABB box More...
 
static bool IntersectSphereWithOOBBox (Vector3 center, float radius, Matrix4x4 matrix, Vector3 min, Vector3 max)
 Determines if a sphere intersects with an OOBB box More...
 
static bool IntersectSphereWithCapsule (Vector3 sphereCenter, float sphereRadius, Vector3 capsulePoint0, Vector3 capsulePoint1, float capsuleRadius, out Vector3 pushBackVector)
 Determines if a sphere intersects with a capsule More...
 
static bool IntersectTriangleOOBBox (Vector3 point0Seg, Vector3 point1Seg, Vector3 point2Seg, Matrix4x4 matrixBox, Vector3 minBox, Vector3 maxBox)
 Determines if a triangle intersects with an OOBB box More...
 

Detailed Description

Class of static functions to help with intersection calculations

Member Function Documentation

◆ ClosestPointsLineToLine()

static bool IntersectionHelper.ClosestPointsLineToLine ( Vector3  p1,
Vector3  p2,
Vector3  p3,
Vector3  p4,
out Vector3  pa,
out Vector3  pb 
)
static

Gets the closest point between two infinite lines.

Parameters
p1A point on the first line
p2Another point on the first line
p3A point on the second line
p4Another point on the second line
paThe closest point (on the first line) between the two lines
pbThe closest point (on the second line) between the two lines
Returns
Returns true if the operation is successful. It may fail if the points do not form a line (ie they are equal)

◆ DistanceLineLine()

static float IntersectionHelper.DistanceLineLine ( Vector3  lineAPoint,
Vector3  lineADirection,
Vector3  lineBPoint,
Vector3  lineBDirection 
)
static

Gets the shortest distance between two infinite lines.

Parameters
lineAPointA point that the first line passes through
lineADirectionThe normalized direction vector of the first line
lineBPointA point that the second line passes through
lineBDirectionThe normalized direction vector of the second line.
Returns
Returns the shortest distance between the two lines.

◆ GetPlaneFromTriangle()

static bool IntersectionHelper.GetPlaneFromTriangle ( Vector3  t0,
Vector3  t1,
Vector3  t2,
out Vector3  outPlanePoint,
out Vector3  outPlaneNormal 
)
static

Gets a point and normal direction representing the plane containing a given triangle.

Parameters
t0The first point of the triangle
t1The second point of the triangle
t2The third point of the triangle
outPlanePoint[output] A point on the plane
outPlaneNormal[output] The direction of the normal of the plane
Returns
Returns true if the operation was successful. It may fail if the input points do not form a triangle.

◆ IntersectAABBoxWithOOBBox()

static bool IntersectionHelper.IntersectAABBoxWithOOBBox ( Vector3  minA,
Vector3  maxA,
Matrix4x4  matrixB,
Vector3  minB,
Vector3  maxB 
)
static

Determines if an AABB box intersects with an OOBB box.

Parameters
minAThe minimum extents of the AABB box
maxAThe maximum extents of the AABB box
matrixBThe matrix representing the position, rotation and scale of the OOBB box. This matrix would be equivalent to Matrix4x4.TRS(positionVector, rotationQuat, scaleVector)
minBThe minimum extents (in local space) of the OOBB box
maxBThe maximum extents (in local space) of the OOBB box
Returns
Returns true the AABB box intersects with the OOBB box

◆ IntersectCapsuleWithCapsule() [1/2]

static bool IntersectionHelper.IntersectCapsuleWithCapsule ( Vector3  capsule0Point0,
Vector3  capsule0Point1,
float  capsule0Radius,
Vector3  capsule1Point0,
Vector3  capsule1Point1,
float  capsule1Radius 
)
static

Determines if a capsule intersects with another capsule

Parameters
capsule0Point0The base point of the first capsule
capsule0Point1The end point of the first capsule
capsule0RadiusThe radius of the first capsule
capsule1Point0The base point of the second capsule
capsule1Point1The end point of the second capsule
capsule1RadiusThe radius of the second capsule
Returns
Returns true if the two capsules intersect

◆ IntersectCapsuleWithCapsule() [2/2]

static bool IntersectionHelper.IntersectCapsuleWithCapsule ( Vector3  capsule0Point0,
Vector3  capsule0Point1,
float  capsule0Radius,
Vector3  capsule1Point0,
Vector3  capsule1Point1,
float  capsule1Radius,
out Vector3  collisionPointOnCapsule1,
out Vector3  pushBackVector 
)
static

Determines if a capsule intersects with another capsule, returning the intersection point on the outer surface of capsule1 and the pushback vector to separate capsule1 away from capsule0

Parameters
capsule0Point0The base point of the first capsule
capsule0Point1The end point of the first capsule
capsule0RadiusThe radius of the first capsule
capsule1Point0The base point of the second capsule
capsule1Point1The end point of the second capsule
capsule1RadiusThe radius of the second capsule
collisionPointOnCapsule1[output] The collision point on the outer surface of the second capsule, if the two capsules intersect
pushBackVector[output] The pushback vector that needs to be applied on the second capsule to separate the capsules.
Returns
Returns true if the two capsules intersect

◆ IntersectInfinitePlaneWithInfinitePlane()

static bool IntersectionHelper.IntersectInfinitePlaneWithInfinitePlane ( Vector3  planeNormal0,
Vector3  planePoint0,
Vector3  planeNormal1,
Vector3  planePoint1,
out Vector3  linePoint,
out Vector3  lineDirection 
)
static

Determines if two planes intersect. If yes, it also returns the line that intersects the two planes.

Parameters
planeNormal0The normal direction of the first plane
planePoint0A point on the first plane
planeNormal1The normal direction of the second plane
planePoint1A point on the second plane
linePoint[output] A point on the line that intersects the two planes
lineDirection[output] The direction vector of the line that intersects the two planes
Returns
Returns true if the two planes intersect

◆ IntersectLineWithCapsule()

static int IntersectionHelper.IntersectLineWithCapsule ( Vector3  pointOnLine,
Vector3  lineDirection,
Vector3  capsuleOrigin,
Vector3  capsuleDirection,
float  capsuleRadius,
out float []  afT 
)
static

Determines if an infinite line intersects a capsule

Parameters
pointOnLineA point on the line
lineDirectionThe normalised direction vector of the line
capsuleOriginThe origin of the capsule
capsuleDirectionThe direction vector of the capsule, multiplied by the length of the capsule
capsuleRadiusThe radius of the capsule
afT[output] Array (size 2) of t-values of the line that represent the intersection points
Returns
Returns the number of intersection points between the line and the capsule

◆ IntersectLineWithInfinitePlane()

static bool IntersectionHelper.IntersectLineWithInfinitePlane ( Vector3  linePoint,
Vector3  lineDir,
Vector3  planePoint,
Vector3  planeDir,
out Vector3  intersectionPoint 
)
static

Determines if a line intersects with a plane, and if yes, also returns the intersection point.

Parameters
linePointA point on the line
lineDirThe normalised direction vector of the line
planePointA point on the plane
planeDirThe normal of the plane
intersectionPoint[output] The intersection point between the line and the plane
Returns
Returns true if the line intersects the plane

◆ IntersectLineWithLine()

static bool IntersectionHelper.IntersectLineWithLine ( Vector3  line0Point,
Vector3  line0Vec,
Vector3  line1Point,
Vector3  line1Vec,
out Vector3  intersectionPoint 
)
static

Determines if two infinite lines intersect each other

Parameters
line0PointA point on the first line
line0VecThe normalised direction vector of the first line
line1PointA point on the second line
line1VecThe normalised direction vector of the second line
intersectionPoint[output] The intersection point of the two lines
Returns
Returns true if the lines intersect each other

◆ IntersectLineWithTriangle()

static bool IntersectionHelper.IntersectLineWithTriangle ( Vector3  linePoint,
Vector3  lineDir,
Vector3  t0,
Vector3  t1,
Vector3  t2,
out Vector3  outContact 
)
static

Determines if a infinite line intersects with a triangle, and if yes, also returns the intersection point.

Parameters
linePointA point on the line
lineDirThe normalised direction vector of the line
t0The first point of the triangle
t1The second point of the triangle
t2The third point of the triangle
outContact[output] The intersection point of the line and the triangle
Returns
Returns true if the line intersects the triangle

◆ IntersectOOBBoxWithOOBBox()

static bool IntersectionHelper.IntersectOOBBoxWithOOBBox ( Matrix4x4  matrixA,
Vector3  minA,
Vector3  maxA,
Matrix4x4  matrixB,
Vector3  minB,
Vector3  maxB 
)
static

Determines if an OOBB box intersects another OOBB box

Parameters
matrixAThe matrix representing the position, rotation and scale of the first OOBB box. This matrix would be equivalent to Matrix4x4.TRS(positionVector, rotationQuat, scaleVector)
minAThe minimum extents (in local space) of the first OOBB box
maxAThe maximum extents (in local space) of the first OOBB box
matrixBThe matrix representing the position, rotation and scale of the second OOBB box. This matrix would be equivalent to Matrix4x4.TRS(positionVector, rotationQuat, scaleVector)
minBThe minimum extents (in local space) of the second OOBB box
maxBThe maximum extents (in local space) of the second OOBB box
Returns
Returns true if the boxes intersect each other

◆ IntersectPointWithAABBox()

static bool IntersectionHelper.IntersectPointWithAABBox ( Vector3  point,
Vector3  minA,
Vector3  maxA 
)
static

Determines if a point lies inside an AABB box

Parameters
pointThe coordinates of the point
minAThe minimum extents of the AABB box
maxAThe maximum extents of the AABB box
Returns
Returns true if the point lies inside the box

◆ IntersectPointWithCapsule()

static bool IntersectionHelper.IntersectPointWithCapsule ( Vector3  point,
Vector3  capsulePoint0,
Vector3  capsulePoint1,
float  capsuleRadius 
)
static

Determines if a point lies inside a capsule

Parameters
pointThe coordinates of the point
capsulePoint0The coordinates of the base of the capsule
capsulePoint1The coordinates of the end of the capsule
capsuleRadiusThe radius of the capsule
Returns
Returns true if the point lies inside the capsule

◆ IntersectPointWithOOBBox()

static bool IntersectionHelper.IntersectPointWithOOBBox ( Vector3  point,
Matrix4x4  matrix,
Vector3  min,
Vector3  max 
)
static

Determines if a point lies inside an OOBB box

Parameters
pointThe coordinates of the point
matrixThe matrix representing the position, rotation and scale of the OOBB box. This matrix would be equivalent to Matrix4x4.TRS(positionVector, rotationQuat, scaleVector)
minThe minimum extents (in local space) of the OOBB box
maxThe maximum extents (in local space) of the OOBB box
Returns
Returns true if the point lies inside the box

◆ IntersectPointWithSphere()

static bool IntersectionHelper.IntersectPointWithSphere ( Vector3  point,
Vector3  center,
float  radius 
)
static

Determines if a point lies inside a sphere

Parameters
pointThe coordinates of the point
centerThe coordinates of the center of the sphere
radiusThe radius of the sphere
Returns
Returns true if the point lies inside the sphere

◆ IntersectPointWithTube()

static bool IntersectionHelper.IntersectPointWithTube ( Vector3  point,
Vector3  tubeStart,
Vector3  tubeEnd,
float  radiusStart,
float  radiusEnd 
)
static

Determines if a point lies inside a tube

Parameters
pointThe coordinates of the point
tubeStartThe first end of the tube
tubeEndThe other end of the tube
radiusStartThe radius of the tube at the first end
radiusEndThe radius of the tube at the other end
Returns
Returns true if the point lies inside the tube

◆ IntersectRayAABBox()

static bool IntersectionHelper.IntersectRayAABBox ( Vector3  originRay,
Vector3  dirRay,
Vector3  minBox,
Vector3  maxBox,
out Vector3  coord 
)
static

Determines if a ray starting from a given point intersects with an AABB box

Parameters
originRayThe origin of the ray
dirRayThe normalised direction vector of the ray
minBoxThe minimum extents of the AABB box
maxBoxThe maximum extents of the AABB box
coord[output] The coordinates of the intersection point
Returns
Returns true if the ray intersects the AABB box

◆ IntersectRayOOBBox()

static bool IntersectionHelper.IntersectRayOOBBox ( Vector3  originRay,
Vector3  dirRay,
Matrix4x4  matrixBox,
Vector3  minBox,
Vector3  maxBox,
out Vector3  coord 
)
static

Determines if a ray starting from a given point intersects with an OOBB box

Parameters
originRayThe origin of the ray
dirRayThe normalised direction vector of the ray
matrixBoxThe matrix representing the position, rotation and scale of the OOBB box. This matrix would be equivalent to Matrix4x4.TRS(positionVector, rotationQuat, scaleVector)
minBoxThe minimum extents (in local space) of the OOBB box
maxBoxThe maximum extents (in local space) of the OOBB box
coord[output] The coordinates of the intersection point
Returns
Returns true if the ray intersects the OOBB box

◆ IntersectRayWithCylinder()

static bool IntersectionHelper.IntersectRayWithCylinder ( Vector3  rayOrigin,
Vector3  ray,
Vector3  cylinderBasis,
Vector3  cylinderAxis,
float  radius,
float  height,
out float  dist,
out Vector3  hitPoint,
out float  distOnCylinder 
)
static

Determines if a ray starting from a given point intersects with a cylinder

Parameters
rayOriginThe origin of the ray
rayThe normalised direction vector of the ray
cylinderBasisThe coordinates of the base of the cylinder
cylinderAxisThe direction vector of the axis of the cylinder
radiusThe radius of the cylinder
heightThe height of the cylinder
dist[output] The distance of the intersection point from the start of the ray
hitPoint[output] The coordinates of the intersection point
distOnCylinder[output] The distance of the intersection point along the cylinder
Returns
Returns true if the ray intersects the cylinder

◆ IntersectSegmentAABBox()

static bool IntersectionHelper.IntersectSegmentAABBox ( Vector3  point0Seg,
Vector3  point1Seg,
Vector3  minBox,
Vector3  maxBox,
out Vector3  coord0,
out Vector3  coord1 
)
static

Determines if a finite segment intersects an AABB box

Parameters
point0SegThe start of the segment
point1SegThe end of the segment
minBoxThe minimum extents of the AABB box
maxBoxThe maximum extents of the AABB box
coord0[output] The first intersection point
coord1[output] The second intersection point
Returns
Returns true if the segment intersects the AABB box

◆ IntersectSegmentWithCapsule() [1/2]

static int IntersectionHelper.IntersectSegmentWithCapsule ( Vector3  segmentPoint,
Vector3  segmentDirection,
Vector3  capsuleOrigin,
Vector3  capsuleDirection,
float  capsuleRadius,
out Vector3 []  intersectionPoints 
)
static

Determines if a finite segment intersects with a capsule

Parameters
segmentPointThe start of the segment
segmentDirectionThe direction vector of the segment, multiplied by it's length
capsuleOriginThe coordinates of the origin of the capsule
capsuleDirectionThe direction vector of the axis of the capsule
capsuleRadiusThe radius of the capsule
intersectionPoints[output] The intersection points between the segment and the capsule
Returns
Returns the number of intersection points between the segment and the capsule

◆ IntersectSegmentWithCapsule() [2/2]

static bool IntersectionHelper.IntersectSegmentWithCapsule ( Vector3  segmentPoint0,
Vector3  segmentPoint1,
Vector3  capsulePoint0,
Vector3  capsulePoint1,
float  capsuleRadius 
)
static

Determines if a finite segment intersects with a capsule

Parameters
segmentPoint0The start of the segment
segmentPoint1The end of the segment
capsulePoint0The coordinates of the base of the capsule
capsulePoint1The coordinates of the end of the capsule
capsuleRadiusThe radius of the capsule
Returns
Returns true if the segment intersects the capsule.

◆ IntersectSegmentWithInfinitePlane()

static bool IntersectionHelper.IntersectSegmentWithInfinitePlane ( Vector3  p0,
Vector3  p1,
Vector3  planeOrigin,
Vector3  planeNormal,
out Vector3  outContact 
)
static

Determines if a finite segment intersects with a plane

Parameters
p0The start of the segment
p1The end of the segment
planeOriginA point on the plane
planeNormalThe normal direction vector of the plane
outContact[output] the intersection point of the segment with the plane
Returns
Returns true if the segment intersects the plane.

◆ IntersectSegmentWithOOBBox() [1/2]

static bool IntersectionHelper.IntersectSegmentWithOOBBox ( Vector3  segPoint0,
Vector3  segPoint1,
Matrix4x4  boxMatrix,
Vector3  boxMin,
Vector3  boxMax 
)
static

Determines if a finite segment intersects with an OOBB box

Parameters
segPoint0The start of the segment
segPoint1The end of the segment
boxMatrixThe matrix representing the position, rotation and scale of the OOBB box. This matrix would be equivalent to Matrix4x4.TRS(positionVector, rotationQuat, scaleVector)
boxMinThe minimum extents (in local space) of the OOBB box
boxMaxThe maximum extents (in local space) of the OOBB box
Returns
Returns true if the segment intersects with the OOBB box

◆ IntersectSegmentWithOOBBox() [2/2]

static bool IntersectionHelper.IntersectSegmentWithOOBBox ( Vector3  point0Seg,
Vector3  point1Seg,
Matrix4x4  matrixBox,
Vector3  minBox,
Vector3  maxBox,
out Vector3  coord0,
out Vector3  coord1 
)
static

Determines if a finite segment intersects with an OOBB box, returning the intersection points

Parameters
point0SegThe start of the segment
point1SegThe end of the segment
matrixBoxThe matrix representing the position, rotation and scale of the OOBB box. This matrix would be equivalent to Matrix4x4.TRS(positionVector, rotationQuat, scaleVector)
minBoxThe minimum extents (in local space) of the OOBB box
maxBoxThe maximum extents (in local space) of the OOBB box
coord0[output] The first intersection point
coord1[output] The second intersection point
Returns
Returns true if the segment intersects the OOBB box

◆ IntersectSegmentWithSegment()

static bool IntersectionHelper.IntersectSegmentWithSegment ( Vector3  segAPoint0,
Vector3  segAPoint1,
Vector3  segBPoint0,
Vector3  segBPoint1,
out Vector3  intersectionPoint,
out float  sFactor,
out float  tFactor 
)
static

Determines if two finite segments intersect

Parameters
segAPoint0The start of the first segment
segAPoint1The end of the first segment
segBPoint0The start of the second segment
segBPoint1A end on the second plane
sFactor[output] The ratio of the intersection point along the first segment
tFactor[output] The ratio of the intersection point along the second segment
intersectionPoint[output] The intersection point of the two segments
Returns
Returns true if the two segments intersect

◆ IntersectSegmentWithSphere()

static bool IntersectionHelper.IntersectSegmentWithSphere ( Vector3  segPoint0,
Vector3  segPoint1,
Vector3  sphereCenter,
float  sphereRadius 
)
static

Determines if a finite segment intersects a sphere

Parameters
segPoint0The start of the segment
segPoint1The end of the segment
sphereCenterThe point at the center of the sphere
sphereRadiusThe radius of the sphere
Returns
Returns true if the segment intersects the sphere

◆ IntersectSegmentWithTriangle()

static bool IntersectionHelper.IntersectSegmentWithTriangle ( Vector3  p0,
Vector3  p1,
Vector3  t0,
Vector3  t1,
Vector3  t2,
out Vector3  outContact 
)
static

Determines if a finite segment intersects with a triangle

Parameters
p0The start of the segment
p1The end of the segment
t0The first point of the triangle
t1The second point of the triangle
t2The third point of the triangle
outContact[output] the intersection point of the segment with the triangle
Returns
Returns true if the segment intersects the triangle.

◆ IntersectSphereWithAABBox()

static bool IntersectionHelper.IntersectSphereWithAABBox ( Vector3  center,
float  radius,
Vector3  min,
Vector3  max 
)
static

Determines if a sphere intersects with an AABB box

Parameters
centerThe point at the center of the sphere
radiusThe radius of the sphere
minThe minimum extents of the AABB box
maxThe maximum extents of the AABB box
Returns
Returns true if the sphere intersects the AABB box

◆ IntersectSphereWithCapsule()

static bool IntersectionHelper.IntersectSphereWithCapsule ( Vector3  sphereCenter,
float  sphereRadius,
Vector3  capsulePoint0,
Vector3  capsulePoint1,
float  capsuleRadius,
out Vector3  pushBackVector 
)
static

Determines if a sphere intersects with a capsule

Parameters
sphereCenterThe point at the center of the sphere
sphereRadiusThe radius of the sphere
capsulePoint0The base of the capsule
capsulePoint1The end of the capsule
capsuleRadiusThe radius of the capsule
pushBackVector[output] The pushback vector to separate the sphere from the capsule
Returns
Returns true if the sphere intersects the capsule

◆ IntersectSphereWithOOBBox()

static bool IntersectionHelper.IntersectSphereWithOOBBox ( Vector3  center,
float  radius,
Matrix4x4  matrix,
Vector3  min,
Vector3  max 
)
static

Determines if a sphere intersects with an OOBB box

Parameters
centerThe point at the center of the sphere
radiusThe radius of the sphere
matrixThe matrix representing the position, rotation and scale of the OOBB box. This matrix would be equivalent to Matrix4x4.TRS(positionVector, rotationQuat, scaleVector)
minThe minimum extents (in local space) of the OOBB box
maxThe maximum extents (in local space) of the OOBB box
Returns
Returns true if the sphere intersects the OOBB box

◆ IntersectTriangleOOBBox()

static bool IntersectionHelper.IntersectTriangleOOBBox ( Vector3  point0Seg,
Vector3  point1Seg,
Vector3  point2Seg,
Matrix4x4  matrixBox,
Vector3  minBox,
Vector3  maxBox 
)
static

Determines if a triangle intersects with an OOBB box

Parameters
point0SegThe first point of the triangle
point1SegThe second point of the triangle
point2SegThe third point of the triangle
matrixBoxThe matrix representing the position, rotation and scale of the OOBB box. This matrix would be equivalent to Matrix4x4.TRS(positionVector, rotationQuat, scaleVector)
minBoxThe minimum extents (in local space) of the OOBB box
maxBoxThe maximum extents (in local space) of the OOBB box
Returns
Returns true if the triangle intersects the OOBB box

◆ IsPointInTriangle()

static bool IntersectionHelper.IsPointInTriangle ( Vector3  p0,
Vector3  p1,
Vector3  p2,
Vector3  point 
)
static

Checks if a point lies inside a triangle

Parameters
p0The first point of the triangle
p1The second point of the triangle
p2The third point of the triangle
pointThe position of the desired point.
Returns
Returns true if the point lies inside the triangle

◆ PointSegmentProjection()

static Vector3 IntersectionHelper.PointSegmentProjection ( Vector3  point,
Vector3  segPoint0,
Vector3  segPoint1 
)
static

Gets the projection of a point on a finite line segment.

Parameters
pointThe input point
segPoint0The start of the line segment
segPoint1The end of the line segment
Returns
Returns the projected point on the segment

◆ SqrDistancePointTriangle()

static float IntersectionHelper.SqrDistancePointTriangle ( Vector3  point,
Vector3  triangle0,
Vector3  triangle1,
Vector3  triangle2,
out Vector3  closestPoint 
)
static

Gets the square of shortest distance between a point and a triangle in 3D space.

Parameters
pointThe position of the desired point.
triangle0The first point of the triangle
triangle1The second point of the triangle
triangle2The third point of the triangle
closestPoint[output] The closest point (on the plane) to the input point.
Returns
Returns the square of shortest distance between the plane and the input point.

◆ SqrDistanceSegmentToSegment()

static float IntersectionHelper.SqrDistanceSegmentToSegment ( Vector3  segment0Point0,
Vector3  segment0Point1,
Vector3  segment1Point0,
Vector3  segment1Point1,
out float  closestPoint0,
out float  closestPoint1 
)
static

Gets the square of shortest distance between two finite line segments.

Parameters
segment0Point0The start position of the first segment
segment0Point1The end position of the first segment
segment1Point0The start position of the second segment
segment1Point1The end position of the second segment
closestPoint0[output] The ratio (along the first segment) of the closest point.
closestPoint1The ratio (along the second segment) of the closest point.
Returns
Returns the square of shortest distance between the two segments.

The documentation for this class was generated from the following file: