A collection of collision helper functions. More...
Static Public Member Functions | |
static Boolean | BoxIntersectsBox (FPVector2 aCenter, FPVector2 aExtents, FP aRotation, FPVector2 bCenter, FPVector2 bExtents, FP bRotation) |
Box-Box (2D) intersection test. More... | |
static Boolean | CircleContainsPoint (FPVector2 center, FP radius, FPVector2 point) |
Checks if point is inside a circle, including its circumference. Works for CW and CWW. More... | |
static Boolean | CircleIntersectsAABB (FPVector2 center, FP radius, FPVector2 min, FPVector2 max) |
Circle-AABB intersection test. More... | |
static Boolean | CircleIntersectsCircle (FPVector2 a_origin, FP a_radius, FPVector2 b_origin, FP b_radius) |
Circle-circle intersection test. More... | |
static Boolean | CircleIntersectsPolygon (FPVector2 circleCenter, FP circleRadius, FPVector2 polygonPosition, FP polygonRotation, FPVector2[] polygonVertices, FPVector2[] polygonNormals) |
Circle-polygon intersection test. More... | |
static Boolean | CircleIntersectsPolygon (FPVector2 circleCenter, FP circleRadius, FPVector2 polygonPosition, FP polygonRotationSinInverse, FP polygonRotationCosInverse, FPVector2[] polygonVertices, FPVector2[] polygonNormals) |
Circle-polygon intersection test. More... | |
static Boolean | CircleIntersectsTriangle (FPVector2 center, FP radius, FPVector2 v1, FPVector2 v2, FPVector2 v3) |
Circle-triangle intersection test. More... | |
static FP | ClosestDistanceToTriangle (FPVector3 p, FPVector3 a, FPVector3 b, FPVector3 c, out FPVector3 closestPoint, out FPVector3 barycentricCoordinates) |
Uses barycentric coordinates to calculate the closest point on a triangle. In conjunction with Fixed Point math this can get quite inaccurate when the triangle become large (more than 100 units) or tiny (less then 0.01 units). More... | |
static FPVector2 | ClosestPointOnCicle (FPVector2 center, FP radius, FPVector2 pt) |
Casts a point pt on a circle. More... | |
static FPVector2 | ClosestPointOnSegment (FPVector2 point, FPVector2 p1, FPVector2 p2) |
Cast point point on a line crossing p1 and p2 . The result is clamped to lie on a segment defined by p1 and p2 . More... | |
static FPVector2 | ClosestPointOnTriangle (FPVector2 pt, FPVector2 t0, FPVector2 t1, FPVector2 t2) |
Casts a point pt on a triangle defined by three vertices. More... | |
static Boolean | InsideAABB (FPVector2 point, FPVector2 extents, out FP penetration) |
Returns true if point is inside centered AABB. More... | |
static bool | IsPointOnLine (FPVector2 p1, FPVector2 p2, FPVector2 point) |
Returns true if a point point lies on a line crossing p1 and p2 . More... | |
static Int32 | LineIntersectsAABB (FPVector2 p1, FPVector2 p2, FPVector2 aabbCenter, FPVector2 aabbExtents, out FPVector2 i1, out FPVector2 i2, out FP penetration) |
Line segment-AABB intersection test in world space with computation of intersection points and penetration. More... | |
static Int32 | LineIntersectsAABB (FPVector2 p1, FPVector2 p2, FPVector2 aabbExtents, out FPVector2 i1, out FPVector2 i2, out FP penetration) |
Line segment-AABB intersection test in the LOCAL space of the AABB with computation of intersection points and penetration. More... | |
static Boolean | LineIntersectsAABB2 (FPVector2 p1, FPVector2 p2, FPVector2 normal, FPVector2 aabbCenter, FPVector2 aabbExtents, out FPVector2 i1, out FPVector2 i2, out FP penetration) |
Line segment-AABB intersection test in world space with computation of intersection points, normal and penetration. If an intersection is detected, the test always returns two intersection points, which can be either intersections between the line segment and an edge of the AABB or a segment point itself, if inside the AABB. More... | |
static Boolean | LineIntersectsAABB2 (FPVector2 p1, FPVector2 p2, FPVector2 normal, FPVector2 aabbExtents, out FPVector2 i1, out FPVector2 i2, out FP penetration) |
Line segment-AABB intersection test in the LOCAL space of the AABB with computation of intersection points, normal and penetration. If an intersection is detected, the test always returns two intersection points, which can be either intersections between the line segment and an edge of the AABB or a segment point itself, if inside the AABB. More... | |
static Boolean | LineIntersectsAABB_SAT (FPVector2 p1, FPVector2 p2, FPVector2 aabbCenter, FPVector2 aabbExtents) |
Line segment-AABB intersection test. More... | |
static Boolean | LineIntersectsAABB_SAT (FPVector2 p1, FPVector2 p2, FPVector2 aabbExtents) |
Line segment-AABB intersection test in the LOCAL space of the AABB. More... | |
static Boolean | LineIntersectsCircle (FPVector2 p1, FPVector2 p2, FPVector2 position, FP radius, bool ignoreIfStartPointInside=false) |
Line segment-circle intersection test. More... | |
static Boolean | LineIntersectsCircle (FPVector2 p1, FPVector2 p2, FPVector2 position, FP radius, out FPVector2 point, bool ignoreIfStartPointInside=false) |
Line segment-circle intersection test. More... | |
static Boolean | LineIntersectsCircle (FPVector2 p1, FPVector2 p2, FPVector2 position, FP radius, out FPVector2 point, out FP normalizedDist, bool ignoreIfStartPointInside=false) |
Line segment-circle intersection test. More... | |
static Boolean | LineIntersectsCircleManifold (FPVector2 p1, FPVector2 p2, FPVector2 position, FP radius, out FPVector2 point) |
Line segment-circle intersection test. More... | |
static bool | LineIntersectsLine (FPVector2 p1, FPVector2 p2, FPVector2 q1, FPVector2 q2) |
Line segment-line segment intersection test. More... | |
static bool | LineIntersectsLine (FPVector2 p1, FPVector2 p2, FPVector2 q1, FPVector2 q2, out FPVector2 point) |
Line segment-line segment intersection test. More... | |
static bool | LineIntersectsLine (FPVector2 p1, FPVector2 p2, FPVector2 q1, FPVector2 q2, out FPVector2 point, out FP distance) |
Line segment-line segment intersection test. More... | |
static void | LineIntersectsLineAlwaysHit (FPVector2 p1, FPVector2 p2, FPVector2 q1, FPVector2 q2, out FPVector2 point) |
Line segment-line segment intersection test. Assumes lines are not colinear nor parallel. More... | |
static FPVector2 | TriangleCenter (FPVector2 v0, FPVector2 v1, FPVector2 v2) |
Returns the center of a triangle defined by three vertices. More... | |
static Boolean | TriangleContainsPointExclusive (FPVector2 pt, FPVector2 v0, FPVector2 v1, FPVector2 v2) |
Checks if pt is inside a triangle, excluding vertices and edges. Works for CW and CWW. More... | |
static Boolean | TriangleContainsPointExclusive (FPVector3 pt, FPVector3 v0, FPVector3 v1, FPVector3 v2) |
Checks if pt is inside a triangle, excluding vertices and edges. This only checks the XZ component like the triangle is in 2D! Works for CW and CWW. More... | |
static Boolean | TriangleContainsPointInclusive (FPVector2 pt, FPVector2 v0, FPVector2 v1, FPVector2 v2) |
Checks if pt is inside a triangle, including edges and vertices. Works for CW and CWW. More... | |
static Boolean | TriangleContainsPointInclusive (FPVector3 pt, FPVector3 v0, FPVector3 v1, FPVector3 v2) |
Checks if pt is inside a triangle, including edges and vertices. This only checks the XZ component like the triangle is in 2D! Works for CW and CWW. More... | |
A collection of collision helper functions.
|
inlinestatic |
Returns the center of a triangle defined by three vertices.
v0 | |
v1 | |
v2 |
|
inlinestatic |
Returns true if a point point lies on a line crossing p1 and p2 .
p1 | |
p2 | |
point |
|
inlinestatic |
Cast point point on a line crossing p1 and p2 . The result is clamped to lie on a segment defined by p1 and p2 .
point | |
p1 | |
p2 |
|
inlinestatic |
Casts a point pt on a triangle defined by three vertices.
pt | |
t0 | |
t1 | |
t2 |
|
inlinestatic |
Casts a point pt on a circle.
center | |
radius | |
pt |
|
inlinestatic |
Checks if pt is inside a triangle, excluding vertices and edges. Works for CW and CWW.
pt | Point to check |
v0 | vertex position 0 |
v1 | vertex position 1 |
v2 | vertex position 2 |
|
inlinestatic |
Checks if pt is inside a triangle, excluding vertices and edges. This only checks the XZ component like the triangle is in 2D! Works for CW and CWW.
pt | Point to check |
v0 | vertex position 0 |
v1 | vertex position 1 |
v2 | vertex position 2 |
|
inlinestatic |
Checks if pt is inside a triangle, including edges and vertices. Works for CW and CWW.
pt | Point to check |
v0 | vertex position 0 |
v1 | vertex position 1 |
v2 | vertex position 2 |
|
inlinestatic |
Checks if pt is inside a triangle, including edges and vertices. This only checks the XZ component like the triangle is in 2D! Works for CW and CWW.
pt | Point to check |
v0 | vertex position 0 |
v1 | vertex position 1 |
v2 | vertex position 2 |
|
inlinestatic |
Checks if point is inside a circle, including its circumference. Works for CW and CWW.
center | |
radius | |
point |
|
inlinestatic |
Circle-circle intersection test.
a_origin | |
a_radius | |
b_origin | |
b_radius |
|
inlinestatic |
Circle-AABB intersection test.
center | |
radius | |
min | |
max |
|
inlinestatic |
Circle-triangle intersection test.
center | |
radius | |
v1 | |
v2 | |
v3 |
|
inlinestatic |
Line segment-AABB intersection test.
p1 | First point that defines the line segment in world space. |
p2 | Second point that defines the line segment in world space. |
aabbCenter | The center of the AABB in world space. |
aabbExtents | The distance between the AABB center and the max X and Y values in world space. |
|
inlinestatic |
Line segment-AABB intersection test in the LOCAL space of the AABB.
p1 | First point that defines the line segment, relative to the AABB center. |
p2 | Second point that defines the line segment, relative to the AABB center. |
aabbExtents | The distance between the AABB center and the max X and Y values. |
|
inlinestatic |
Line segment-AABB intersection test in world space with computation of intersection points, normal and penetration. If an intersection is detected, the test always returns two intersection points, which can be either intersections between the line segment and an edge of the AABB or a segment point itself, if inside the AABB.
p1 | First point that defines the line segment in world space. |
p2 | Second point that defines the line segment in world space. |
normal | Normal along which the line segment penetration will be computed. |
aabbCenter | The center of the AABB in world space. |
aabbExtents | The distance between the AABB center and the max X and Y values in world space. |
i1 | First intersection point. |
i2 | Second intersection point. |
penetration | The penetration of the line segment along the normal . |
|
inlinestatic |
Line segment-AABB intersection test in the LOCAL space of the AABB with computation of intersection points, normal and penetration. If an intersection is detected, the test always returns two intersection points, which can be either intersections between the line segment and an edge of the AABB or a segment point itself, if inside the AABB.
p1 | First point that defines the line segment, relative to the AABB center. |
p2 | Second point that defines the line segment, relative to the AABB center. |
normal | Normal along which the line segment penetration will be computed. |
aabbExtents | The distance between the AABB center and the max X and Y values in world space. |
i1 | First intersection point, relative to the AABB center. |
i2 | Second intersection point, relative to the AABB center. |
penetration | The penetration of the line segment along the normal . |
|
inlinestatic |
Line segment-AABB intersection test in world space with computation of intersection points and penetration.
p1 | First point that defines the line segment in world space. |
p2 | Second point that defines the line segment in world space. |
aabbCenter | The center of the AABB in world space. |
aabbExtents | The distance between the AABB center and the max X and Y values in world space. |
i1 | First intersection point in world space. |
i2 | Second intersection point in world space. |
penetration | The penetration of the line segment along the closest AABB normal. |
|
inlinestatic |
Line segment-AABB intersection test in the LOCAL space of the AABB with computation of intersection points and penetration.
p1 | First point that defines the line segment, relative to the AABB center. |
p2 | Second point that defines the line segment, relative to the AABB center. |
aabbExtents | The distance between the AABB center and the max X and Y values in world space. |
i1 | First intersection point, relative to the AABB center. |
i2 | Second intersection point, relative to the AABB center. |
penetration | The penetration of the line segment along the closest AABB normal. |
|
inlinestatic |
Line segment-line segment intersection test.
p1 | |
p2 | |
q1 | |
q2 |
|
inlinestatic |
Line segment-line segment intersection test.
p1 | |
p2 | |
q1 | |
q2 | |
point | Point of collision |
distance | Distance along p segment where the collision happens |
|
inlinestatic |
Line segment-line segment intersection test.
p1 | |
p2 | |
q1 | |
q2 | |
point | Point of collision |
|
inlinestatic |
Line segment-line segment intersection test. Assumes lines are not colinear nor parallel.
p1 | |
p2 | |
q1 | |
q2 | |
point |
|
inlinestatic |
Returns true if point is inside centered AABB.
point | |
extents | |
penetration |
|
inlinestatic |
Line segment-circle intersection test.
p1 | |
p2 | |
position | |
radius | |
point |
|
inlinestatic |
Line segment-circle intersection test.
p1 | Start point of the line segment. |
p2 | End point of the line segment. |
position | Position of the center of the circle in world space. |
radius | Radius of the circle. |
ignoreIfStartPointInside | If the intersection should be ignored if the start point of the line segment (p1 ) is inside the circle. |
|
inlinestatic |
Line segment-circle intersection test.
p1 | Start point of the line segment. |
p2 | End point of the line segment. |
position | Position of the center of the circle in world space. |
radius | Radius of the circle. |
point | Intersection point, if intersecting. Default otherwise. |
ignoreIfStartPointInside | If the intersection should be ignored if the start point of the line segment (p1 ) is inside the circle. |
|
inlinestatic |
Line segment-circle intersection test.
p1 | Start point of the line segment. |
p2 | End point of the line segment. |
position | Position of the center of the circle in world space. |
radius | Radius of the circle. |
point | Intersection point, if intersecting. Default otherwise. |
normalizedDist | Normalize distance from p1 to p2 of the intersection point, if intersecting. Default otherwise. |
ignoreIfStartPointInside | If the intersection should be ignored if the start point of the line segment (p1 ) is inside the circle. |
|
inlinestatic |
Circle-polygon intersection test.
circleCenter | |
circleRadius | |
polygonPosition | |
polygonRotationSinInverse | |
polygonRotationCosInverse | |
polygonVertices | |
polygonNormals |
|
inlinestatic |
Circle-polygon intersection test.
circleCenter | |
circleRadius | |
polygonPosition | |
polygonRotation | |
polygonVertices | |
polygonNormals |
|
inlinestatic |
Box-Box (2D) intersection test.
aCenter | |
aExtents | |
aRotation | |
bCenter | |
bExtents | |
bRotation |
|
inlinestatic |
Uses barycentric coordinates to calculate the closest point on a triangle. In conjunction with Fixed Point math this can get quite inaccurate when the triangle become large (more than 100 units) or tiny (less then 0.01 units).
p | Point |
a | Vertex 0 |
b | Vertex 1 |
c | Vertex 2 |
closestPoint | Resulting point on the triangle |
barycentricCoordinates | Barycentric coordinates of the point inside the triangle. |