Photon Quantum 2.1.1

Static Public Member Functions | List of all members
Photon.Deterministic.FPCollision Struct Reference

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...
 

Detailed Description

A collection of collision helper functions.

Member Function Documentation

◆ TriangleCenter()

static FPVector2 Photon.Deterministic.FPCollision.TriangleCenter ( FPVector2  v0,
FPVector2  v1,
FPVector2  v2 
)
inlinestatic

Returns the center of a triangle defined by three vertices.

Parameters
v0
v1
v2
Returns

◆ IsPointOnLine()

static bool Photon.Deterministic.FPCollision.IsPointOnLine ( FPVector2  p1,
FPVector2  p2,
FPVector2  point 
)
inlinestatic

Returns true if a point point lies on a line crossing p1 and p2 .

Parameters
p1
p2
point
Returns

◆ ClosestPointOnSegment()

static FPVector2 Photon.Deterministic.FPCollision.ClosestPointOnSegment ( FPVector2  point,
FPVector2  p1,
FPVector2  p2 
)
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 .

Parameters
point
p1
p2
Returns

◆ ClosestPointOnTriangle()

static FPVector2 Photon.Deterministic.FPCollision.ClosestPointOnTriangle ( FPVector2  pt,
FPVector2  t0,
FPVector2  t1,
FPVector2  t2 
)
inlinestatic

Casts a point pt on a triangle defined by three vertices.

Parameters
pt
t0
t1
t2
Returns

◆ ClosestPointOnCicle()

static FPVector2 Photon.Deterministic.FPCollision.ClosestPointOnCicle ( FPVector2  center,
FP  radius,
FPVector2  pt 
)
inlinestatic

Casts a point pt on a circle.

Parameters
center
radius
pt
Returns

◆ TriangleContainsPointExclusive() [1/2]

static Boolean Photon.Deterministic.FPCollision.TriangleContainsPointExclusive ( FPVector2  pt,
FPVector2  v0,
FPVector2  v1,
FPVector2  v2 
)
inlinestatic

Checks if pt is inside a triangle, excluding vertices and edges. Works for CW and CWW.

Parameters
ptPoint to check
v0vertex position 0
v1vertex position 1
v2vertex position 2
Returns
True if pt is inside the triangle. False if point is outside or if the point is located on an edge or vertex.

◆ TriangleContainsPointExclusive() [2/2]

static Boolean Photon.Deterministic.FPCollision.TriangleContainsPointExclusive ( FPVector3  pt,
FPVector3  v0,
FPVector3  v1,
FPVector3  v2 
)
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.

Parameters
ptPoint to check
v0vertex position 0
v1vertex position 1
v2vertex position 2
Returns
True if pt is inside the triangle. False if point is outside or if the point is located on an edge or vertex.

◆ TriangleContainsPointInclusive() [1/2]

static Boolean Photon.Deterministic.FPCollision.TriangleContainsPointInclusive ( FPVector2  pt,
FPVector2  v0,
FPVector2  v1,
FPVector2  v2 
)
inlinestatic

Checks if pt is inside a triangle, including edges and vertices. Works for CW and CWW.

Parameters
ptPoint to check
v0vertex position 0
v1vertex position 1
v2vertex position 2
Returns
True if pt is inside the triangle or is located on an edge or vertex.

◆ TriangleContainsPointInclusive() [2/2]

static Boolean Photon.Deterministic.FPCollision.TriangleContainsPointInclusive ( FPVector3  pt,
FPVector3  v0,
FPVector3  v1,
FPVector3  v2 
)
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.

Parameters
ptPoint to check
v0vertex position 0
v1vertex position 1
v2vertex position 2
Returns
True if pt is inside the triangle or is located on an edge or vertex.

◆ CircleContainsPoint()

static Boolean Photon.Deterministic.FPCollision.CircleContainsPoint ( FPVector2  center,
FP  radius,
FPVector2  point 
)
inlinestatic

Checks if point is inside a circle, including its circumference. Works for CW and CWW.

Parameters
center
radius
point
Returns
true in point point is inside the circle.

◆ CircleIntersectsCircle()

static Boolean Photon.Deterministic.FPCollision.CircleIntersectsCircle ( FPVector2  a_origin,
FP  a_radius,
FPVector2  b_origin,
FP  b_radius 
)
inlinestatic

Circle-circle intersection test.

Parameters
a_origin
a_radius
b_origin
b_radius
Returns

◆ CircleIntersectsAABB()

static Boolean Photon.Deterministic.FPCollision.CircleIntersectsAABB ( FPVector2  center,
FP  radius,
FPVector2  min,
FPVector2  max 
)
inlinestatic

Circle-AABB intersection test.

Parameters
center
radius
min
max
Returns

◆ CircleIntersectsTriangle()

static Boolean Photon.Deterministic.FPCollision.CircleIntersectsTriangle ( FPVector2  center,
FP  radius,
FPVector2  v1,
FPVector2  v2,
FPVector2  v3 
)
inlinestatic

Circle-triangle intersection test.

Parameters
center
radius
v1
v2
v3
Returns

◆ LineIntersectsAABB_SAT() [1/2]

static Boolean Photon.Deterministic.FPCollision.LineIntersectsAABB_SAT ( FPVector2  p1,
FPVector2  p2,
FPVector2  aabbCenter,
FPVector2  aabbExtents 
)
inlinestatic

Line segment-AABB intersection test.

Parameters
p1First point that defines the line segment in world space.
p2Second point that defines the line segment in world space.
aabbCenterThe center of the AABB in world space.
aabbExtentsThe distance between the AABB center and the max X and Y values in world space.
Returns
True if the line segment intersects the AABB and false otherwise.

◆ LineIntersectsAABB_SAT() [2/2]

static Boolean Photon.Deterministic.FPCollision.LineIntersectsAABB_SAT ( FPVector2  p1,
FPVector2  p2,
FPVector2  aabbExtents 
)
inlinestatic

Line segment-AABB intersection test in the LOCAL space of the AABB.

Parameters
p1First point that defines the line segment, relative to the AABB center.
p2Second point that defines the line segment, relative to the AABB center.
aabbExtentsThe distance between the AABB center and the max X and Y values.
Returns
True if the line segment intersects the AABB and false otherwise.

◆ LineIntersectsAABB2() [1/2]

static Boolean Photon.Deterministic.FPCollision.LineIntersectsAABB2 ( FPVector2  p1,
FPVector2  p2,
FPVector2  normal,
FPVector2  aabbCenter,
FPVector2  aabbExtents,
out FPVector2  i1,
out FPVector2  i2,
out FP  penetration 
)
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.

Parameters
p1First point that defines the line segment in world space.
p2Second point that defines the line segment in world space.
normalNormal along which the line segment penetration will be computed.
aabbCenterThe center of the AABB in world space.
aabbExtentsThe distance between the AABB center and the max X and Y values in world space.
i1First intersection point.
i2Second intersection point.
penetrationThe penetration of the line segment along the normal .
Returns
True if the line segment intersects the AABB and false otherwise.

◆ LineIntersectsAABB2() [2/2]

static Boolean Photon.Deterministic.FPCollision.LineIntersectsAABB2 ( FPVector2  p1,
FPVector2  p2,
FPVector2  normal,
FPVector2  aabbExtents,
out FPVector2  i1,
out FPVector2  i2,
out FP  penetration 
)
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.

Parameters
p1First point that defines the line segment, relative to the AABB center.
p2Second point that defines the line segment, relative to the AABB center.
normalNormal along which the line segment penetration will be computed.
aabbExtentsThe distance between the AABB center and the max X and Y values in world space.
i1First intersection point, relative to the AABB center.
i2Second intersection point, relative to the AABB center.
penetrationThe penetration of the line segment along the normal .
Returns
True if the line segment intersects the AABB and false otherwise.

◆ LineIntersectsAABB() [1/2]

static Int32 Photon.Deterministic.FPCollision.LineIntersectsAABB ( FPVector2  p1,
FPVector2  p2,
FPVector2  aabbCenter,
FPVector2  aabbExtents,
out FPVector2  i1,
out FPVector2  i2,
out FP  penetration 
)
inlinestatic

Line segment-AABB intersection test in world space with computation of intersection points and penetration.

Parameters
p1First point that defines the line segment in world space.
p2Second point that defines the line segment in world space.
aabbCenterThe center of the AABB in world space.
aabbExtentsThe distance between the AABB center and the max X and Y values in world space.
i1First intersection point in world space.
i2Second intersection point in world space.
penetrationThe penetration of the line segment along the closest AABB normal.
Returns
The number of intersections found between the line segment and the AABB edges. If less than 2, the respective intersection point will be default.

◆ LineIntersectsAABB() [2/2]

static Int32 Photon.Deterministic.FPCollision.LineIntersectsAABB ( FPVector2  p1,
FPVector2  p2,
FPVector2  aabbExtents,
out FPVector2  i1,
out FPVector2  i2,
out FP  penetration 
)
inlinestatic

Line segment-AABB intersection test in the LOCAL space of the AABB with computation of intersection points and penetration.

Parameters
p1First point that defines the line segment, relative to the AABB center.
p2Second point that defines the line segment, relative to the AABB center.
aabbExtentsThe distance between the AABB center and the max X and Y values in world space.
i1First intersection point, relative to the AABB center.
i2Second intersection point, relative to the AABB center.
penetrationThe penetration of the line segment along the closest AABB normal.
Returns
The number of intersections found between the line segment and the AABB edges. If less than 2, the respective intersection point will be default.

◆ LineIntersectsLine() [1/3]

static bool Photon.Deterministic.FPCollision.LineIntersectsLine ( FPVector2  p1,
FPVector2  p2,
FPVector2  q1,
FPVector2  q2 
)
inlinestatic

Line segment-line segment intersection test.

Parameters
p1
p2
q1
q2
Returns

◆ LineIntersectsLine() [2/3]

static bool Photon.Deterministic.FPCollision.LineIntersectsLine ( FPVector2  p1,
FPVector2  p2,
FPVector2  q1,
FPVector2  q2,
out FPVector2  point,
out FP  distance 
)
inlinestatic

Line segment-line segment intersection test.

Parameters
p1
p2
q1
q2
pointPoint of collision
distanceDistance along p segment where the collision happens
Returns

◆ LineIntersectsLine() [3/3]

static bool Photon.Deterministic.FPCollision.LineIntersectsLine ( FPVector2  p1,
FPVector2  p2,
FPVector2  q1,
FPVector2  q2,
out FPVector2  point 
)
inlinestatic

Line segment-line segment intersection test.

Parameters
p1
p2
q1
q2
pointPoint of collision
Returns

◆ LineIntersectsLineAlwaysHit()

static void Photon.Deterministic.FPCollision.LineIntersectsLineAlwaysHit ( FPVector2  p1,
FPVector2  p2,
FPVector2  q1,
FPVector2  q2,
out FPVector2  point 
)
inlinestatic

Line segment-line segment intersection test. Assumes lines are not colinear nor parallel.

Parameters
p1
p2
q1
q2
point

◆ InsideAABB()

static Boolean Photon.Deterministic.FPCollision.InsideAABB ( FPVector2  point,
FPVector2  extents,
out FP  penetration 
)
inlinestatic

Returns true if point is inside centered AABB.

Parameters
point
extents
penetration
Returns

◆ LineIntersectsCircleManifold()

static Boolean Photon.Deterministic.FPCollision.LineIntersectsCircleManifold ( FPVector2  p1,
FPVector2  p2,
FPVector2  position,
FP  radius,
out FPVector2  point 
)
inlinestatic

Line segment-circle intersection test.

Parameters
p1
p2
position
radius
point
Returns

◆ LineIntersectsCircle() [1/3]

static Boolean Photon.Deterministic.FPCollision.LineIntersectsCircle ( FPVector2  p1,
FPVector2  p2,
FPVector2  position,
FP  radius,
bool  ignoreIfStartPointInside = false 
)
inlinestatic

Line segment-circle intersection test.

Parameters
p1Start point of the line segment.
p2End point of the line segment.
positionPosition of the center of the circle in world space.
radiusRadius of the circle.
ignoreIfStartPointInsideIf the intersection should be ignored if the start point of the line segment (p1 ) is inside the circle.
Returns
True if an intersection is detected. False otherwise.

◆ LineIntersectsCircle() [2/3]

static Boolean Photon.Deterministic.FPCollision.LineIntersectsCircle ( FPVector2  p1,
FPVector2  p2,
FPVector2  position,
FP  radius,
out FPVector2  point,
bool  ignoreIfStartPointInside = false 
)
inlinestatic

Line segment-circle intersection test.

Parameters
p1Start point of the line segment.
p2End point of the line segment.
positionPosition of the center of the circle in world space.
radiusRadius of the circle.
pointIntersection point, if intersecting. Default otherwise.
ignoreIfStartPointInsideIf the intersection should be ignored if the start point of the line segment (p1 ) is inside the circle.
Returns
True if an intersection is detected. False otherwise.

◆ LineIntersectsCircle() [3/3]

static Boolean Photon.Deterministic.FPCollision.LineIntersectsCircle ( FPVector2  p1,
FPVector2  p2,
FPVector2  position,
FP  radius,
out FPVector2  point,
out FP  normalizedDist,
bool  ignoreIfStartPointInside = false 
)
inlinestatic

Line segment-circle intersection test.

Parameters
p1Start point of the line segment.
p2End point of the line segment.
positionPosition of the center of the circle in world space.
radiusRadius of the circle.
pointIntersection point, if intersecting. Default otherwise.
normalizedDistNormalize distance from p1 to p2 of the intersection point, if intersecting. Default otherwise.
ignoreIfStartPointInsideIf the intersection should be ignored if the start point of the line segment (p1 ) is inside the circle.
Returns
True if an intersection is detected. False otherwise.

◆ CircleIntersectsPolygon() [1/2]

static Boolean Photon.Deterministic.FPCollision.CircleIntersectsPolygon ( FPVector2  circleCenter,
FP  circleRadius,
FPVector2  polygonPosition,
FP  polygonRotationSinInverse,
FP  polygonRotationCosInverse,
FPVector2[]  polygonVertices,
FPVector2[]  polygonNormals 
)
inlinestatic

Circle-polygon intersection test.

Parameters
circleCenter
circleRadius
polygonPosition
polygonRotationSinInverse
polygonRotationCosInverse
polygonVertices
polygonNormals
Returns

◆ CircleIntersectsPolygon() [2/2]

static Boolean Photon.Deterministic.FPCollision.CircleIntersectsPolygon ( FPVector2  circleCenter,
FP  circleRadius,
FPVector2  polygonPosition,
FP  polygonRotation,
FPVector2[]  polygonVertices,
FPVector2[]  polygonNormals 
)
inlinestatic

Circle-polygon intersection test.

Parameters
circleCenter
circleRadius
polygonPosition
polygonRotation
polygonVertices
polygonNormals
Returns

◆ BoxIntersectsBox()

static Boolean Photon.Deterministic.FPCollision.BoxIntersectsBox ( FPVector2  aCenter,
FPVector2  aExtents,
FP  aRotation,
FPVector2  bCenter,
FPVector2  bExtents,
FP  bRotation 
)
inlinestatic

Box-Box (2D) intersection test.

Parameters
aCenter
aExtents
aRotation
bCenter
bExtents
bRotation
Returns

◆ ClosestDistanceToTriangle()

static FP Photon.Deterministic.FPCollision.ClosestDistanceToTriangle ( FPVector3  p,
FPVector3  a,
FPVector3  b,
FPVector3  c,
out FPVector3  closestPoint,
out FPVector3  barycentricCoordinates 
)
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).

Parameters
pPoint
aVertex 0
bVertex 1
cVertex 2
closestPointResulting point on the triangle
barycentricCoordinatesBarycentric coordinates of the point inside the triangle.
Returns
Squared distance to point on the triangle.