Open 3D Engine AzCore API Reference  24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::Intersect Namespace Reference

Classes

class  SegmentTriangleHitTester
 

Enumerations

enum  RayAABBIsectTypes : AZ::s32 { ISECT_RAY_AABB_NONE = 0 , ISECT_RAY_AABB_SA_INSIDE , ISECT_RAY_AABB_ISECT }
 Ray aabb intersection result types. More...
 
enum  SphereIsectTypes : AZ::s32 { ISECT_RAY_SPHERE_SA_INSIDE = -1 , ISECT_RAY_SPHERE_NONE , ISECT_RAY_SPHERE_ISECT }
 Ray sphere intersection result types. More...
 
enum  CylinderIsectTypes : AZ::s32 {
  RR_ISECT_RAY_CYL_SA_INSIDE = -1 , RR_ISECT_RAY_CYL_NONE , RR_ISECT_RAY_CYL_PQ , RR_ISECT_RAY_CYL_P_SIDE ,
  RR_ISECT_RAY_CYL_Q_SIDE
}
 Ray cylinder intersection types. More...
 
enum  CapsuleIsectTypes {
  ISECT_RAY_CAPSULE_SA_INSIDE = -1 , ISECT_RAY_CAPSULE_NONE , ISECT_RAY_CAPSULE_PQ , ISECT_RAY_CAPSULE_P_SIDE ,
  ISECT_RAY_CAPSULE_Q_SIDE
}
 Capsule ray intersect types. More...
 

Functions

AZ_MATH_INLINE Vector3 Barycentric (const Vector3 &a, const Vector3 &b, const Vector3 &c, const Vector3 &p)
 
AZ_MATH_INLINE bool TestPointTriangle (const Vector3 &p, const Vector3 &a, const Vector3 &b, const Vector3 &c)
 Test if point p lies inside the triangle (a,b,c).
 
AZ_MATH_INLINE bool TestPointTriangleCCW (const Vector3 &p, const Vector3 &a, const Vector3 &b, const Vector3 &c)
 Test if point p lies inside the counter clock wise triangle (a,b,c).
 
AZ_MATH_INLINE float ClosestPointPlane (const Vector3 &p, const Plane &plane, Vector3 &ptOnPlane)
 
Vector3 ClosestPointTriangle (const Vector3 &p, const Vector3 &a, const Vector3 &b, const Vector3 &c)
 
AZ_INLINE bool PointSphere (const Vector3 &centerPosition, float radiusSquared, const Vector3 &testPoint)
 
AZ_INLINE bool PointCylinder (const AZ::Vector3 &baseCenterPoint, const AZ::Vector3 &axisVector, float axisLengthSquared, float radiusSquared, const AZ::Vector3 &testPoint)
 
float LineToPointDistanceTime (const Vector3 &s1, const Vector3 &s21, const Vector3 &p)
 
Vector3 LineToPointDistance (const Vector3 &s1, const Vector3 &s2, const Vector3 &p, float &u)
 
bool IntersectSegmentTriangleCCW (const Vector3 &p, const Vector3 &q, const Vector3 &a, const Vector3 &b, const Vector3 &c, Vector3 &normal, float &t)
 
bool IntersectSegmentTriangle (const Vector3 &p, const Vector3 &q, const Vector3 &a, const Vector3 &b, const Vector3 &c, Vector3 &normal, float &t)
 
RayAABBIsectTypes IntersectRayAABB (const Vector3 &rayStart, const Vector3 &dir, const Vector3 &dirRCP, const Aabb &aabb, float &tStart, float &tEnd, Vector3 &startNormal)
 
RayAABBIsectTypes IntersectRayAABB2 (const Vector3 &rayStart, const Vector3 &dirRCP, const Aabb &aabb, float &start, float &end)
 
bool ClipRayWithAabb (const Aabb &aabb, Vector3 &rayStart, Vector3 &rayEnd, float &tClipStart, float &tClipEnd)
 
bool TestSegmentAABBOrigin (const Vector3 &midPoint, const Vector3 &halfVector, const Vector3 &aabbExtends)
 
bool TestSegmentAABB (const Vector3 &p0, const Vector3 &p1, const Aabb &aabb)
 
SphereIsectTypes IntersectRaySphereOrigin (const Vector3 &rayStart, const Vector3 &rayDirNormalized, const float sphereRadius, float &t)
 
SphereIsectTypes IntersectRaySphere (const Vector3 &rayStart, const Vector3 &rayDirNormalized, const Vector3 &sphereCenter, const float sphereRadius, float &t)
 
bool IntersectRayDisk (const Vector3 &rayOrigin, const Vector3 &rayDir, const Vector3 &diskCenter, const float diskRadius, const AZ::Vector3 &diskNormal, float &t)
 
int IntersectRayCappedCylinder (const Vector3 &rayOrigin, const Vector3 &rayDir, const Vector3 &cylinderEnd1, const Vector3 &cylinderDir, float cylinderHeight, float cylinderRadius, float &t1, float &t2)
 
int IntersectRayCone (const Vector3 &rayOrigin, const Vector3 &rayDir, const Vector3 &coneApex, const Vector3 &coneDir, float coneHeight, float coneBaseRadius, float &t1, float &t2)
 
int IntersectRayPlane (const Vector3 &rayOrigin, const Vector3 &rayDir, const Vector3 &planePos, const Vector3 &planeNormal, float &t)
 
int IntersectRayQuad (const Vector3 &rayOrigin, const Vector3 &rayDir, const Vector3 &vertexA, const Vector3 &vertexB, const Vector3 &vertexC, const Vector3 &vertexD, float &t)
 
bool IntersectRayBox (const Vector3 &rayOrigin, const Vector3 &rayDir, const Vector3 &boxCenter, const Vector3 &boxAxis1, const Vector3 &boxAxis2, const Vector3 &boxAxis3, float boxHalfExtent1, float boxHalfExtent2, float boxHalfExtent3, float &t)
 
bool IntersectRayObb (const Vector3 &rayOrigin, const Vector3 &rayDir, const Obb &obb, float &t)
 
CylinderIsectTypes IntersectSegmentCylinder (const Vector3 &sa, const Vector3 &dir, const Vector3 &p, const Vector3 &q, const float r, float &t)
 
CapsuleIsectTypes IntersectSegmentCapsule (const Vector3 &sa, const Vector3 &dir, const Vector3 &p, const Vector3 &q, const float r, float &t)
 
bool IntersectSegmentPolyhedron (const Vector3 &sa, const Vector3 &dir, const Plane p[], int numPlanes, float &tfirst, float &tlast, int &iFirstPlane, int &iLastPlane)
 
void ClosestSegmentSegment (const Vector3 &segment1Start, const Vector3 &segment1End, const Vector3 &segment2Start, const Vector3 &segment2End, float &segment1Proportion, float &segment2Proportion, Vector3 &closestPointSegment1, Vector3 &closestPointSegment2, float epsilon=1e-4f)
 
void ClosestSegmentSegment (const Vector3 &segment1Start, const Vector3 &segment1End, const Vector3 &segment2Start, const Vector3 &segment2End, Vector3 &closestPointSegment1, Vector3 &closestPointSegment2, float epsilon=1e-4f)
 
void ClosestPointSegment (const Vector3 &point, const Vector3 &segmentStart, const Vector3 &segmentEnd, float &proportion, Vector3 &closestPointOnSegment)
 
float PointSegmentDistanceSq (const Vector3 &point, const Vector3 &segmentStart, const Vector3 &segmentEnd)
 

Detailed Description

Intersect

This namespace contains, primitive intersections and overlapping tests. reference RealTimeCollisionDetection, CollisionDetection in interactive 3D environments, etc.

Enumeration Type Documentation

◆ CapsuleIsectTypes

Capsule ray intersect types.

Enumerator
ISECT_RAY_CAPSULE_SA_INSIDE 

The ray starts inside the cylinder.

ISECT_RAY_CAPSULE_NONE 

No intersection.

ISECT_RAY_CAPSULE_PQ 

Along the PQ segment.

ISECT_RAY_CAPSULE_P_SIDE 

On the P side.

ISECT_RAY_CAPSULE_Q_SIDE 

On the Q side.

◆ CylinderIsectTypes

Ray cylinder intersection types.

Enumerator
RR_ISECT_RAY_CYL_SA_INSIDE 

the ray starts inside the cylinder

RR_ISECT_RAY_CYL_NONE 

no intersection

RR_ISECT_RAY_CYL_PQ 

along the PQ segment

RR_ISECT_RAY_CYL_P_SIDE 

on the P side

RR_ISECT_RAY_CYL_Q_SIDE 

on the Q side

◆ RayAABBIsectTypes

Ray aabb intersection result types.

Enumerator
ISECT_RAY_AABB_NONE 

no intersection

ISECT_RAY_AABB_SA_INSIDE 

the ray starts inside the aabb

ISECT_RAY_AABB_ISECT 

intersects along the PQ segment

◆ SphereIsectTypes

Ray sphere intersection result types.

Enumerator
ISECT_RAY_SPHERE_SA_INSIDE 

The ray starts inside the cylinder.

ISECT_RAY_SPHERE_NONE 

No intersection.

ISECT_RAY_SPHERE_ISECT 

Along the PQ segment.

Function Documentation

◆ Barycentric()

AZ_MATH_INLINE Vector3 AZ::Intersect::Barycentric ( const Vector3 a,
const Vector3 b,
const Vector3 c,
const Vector3 p 
)

Compute barycentric coordinates (u,v,w) for a point P with respect to triangle (a,b,c).

◆ ClipRayWithAabb()

AZ_MATH_INLINE bool AZ::Intersect::ClipRayWithAabb ( const Aabb aabb,
Vector3 rayStart,
Vector3 rayEnd,
float &  tClipStart,
float &  tClipEnd 
)

Clip a ray to an aabb. return true if ray was clipped. The ray can be inside so don't use the result if the ray intersect the box.

Parameters
aabbBounds to test against.
rayStartThe start of the ray.
rayEndThe end of the ray.
[out]tClipStartThe proportion where the ray enters the Aabb.
[out]tClipEndThe proportion where the ray exits the Aabb.
Returns
True if the ray was clipped, otherwise false.

◆ ClosestPointPlane()

AZ_MATH_INLINE float AZ::Intersect::ClosestPointPlane ( const Vector3 p,
const Plane plane,
Vector3 ptOnPlane 
)

Find the closest point to 'p' on a plane 'plane'.

Parameters
[out]ptOnPlaneclosest point on the plane.
Returns
Distance from the 'p' to 'ptOnPlane'.

◆ ClosestPointSegment()

void AZ::Intersect::ClosestPointSegment ( const Vector3 point,
const Vector3 segmentStart,
const Vector3 segmentEnd,
float &  proportion,
Vector3 closestPointOnSegment 
)

Calculate the point (closestPointOnSegment) that is the closest point on segment segmentStart/segmentEnd to point. Also calculate the value of proportion where closestPointOnSegment = segmentStart + (proportion * (segmentEnd - segmentStart))

Parameters
pointThe point to test
segmentStartThe start of the segment
segmentEndThe end of the segment
[out]proportionThe proportion of the segment L(t) = (end - start) * t
[out]closestPointOnSegmentThe point along the line segment

◆ ClosestPointTriangle()

Vector3 AZ::Intersect::ClosestPointTriangle ( const Vector3 p,
const Vector3 a,
const Vector3 b,
const Vector3 c 
)
inline

Find the closest point to 'p' on a triangle (a,b,c).

Returns
closest point to 'p' on the triangle (a,b,c).

◆ ClosestSegmentSegment() [1/2]

void AZ::Intersect::ClosestSegmentSegment ( const Vector3 segment1Start,
const Vector3 segment1End,
const Vector3 segment2Start,
const Vector3 segment2End,
float &  segment1Proportion,
float &  segment2Proportion,
Vector3 closestPointSegment1,
Vector3 closestPointSegment2,
float  epsilon = 1e-4f 
)

Calculate the line segment closestPointSegment1<->closestPointSegment2 that is the shortest route between two segments segment1Start<->segment1End and segment2Start<->segment2End. Also calculate the values of segment1Proportion and segment2Proportion where closestPointSegment1 = segment1Start + (segment1Proportion * (segment1End - segment1Start)) closestPointSegment2 = segment2Start + (segment2Proportion * (segment2End - segment2Start)) If segments are parallel returns a solution.

Parameters
segment1StartStart of segment 1.
segment1EndEnd of segment 1.
segment2StartStart of segment 2.
segment2EndEnd of segment 2.
[out]segment1ProportionThe proporition along segment 1 [0..1]
[out]segment2ProportionThe proporition along segment 2 [0..1]
[out]closestPointSegment1Closest point on segment 1.
[out]closestPointSegment2Closest point on segment 2.
epsilonThe minimum square distance where a line segment can be treated as a single point.

◆ ClosestSegmentSegment() [2/2]

void AZ::Intersect::ClosestSegmentSegment ( const Vector3 segment1Start,
const Vector3 segment1End,
const Vector3 segment2Start,
const Vector3 segment2End,
Vector3 closestPointSegment1,
Vector3 closestPointSegment2,
float  epsilon = 1e-4f 
)

Calculate the line segment closestPointSegment1<->closestPointSegment2 that is the shortest route between two segments segment1Start<->segment1End and segment2Start<->segment2End. If segments are parallel returns a solution.

Parameters
segment1StartStart of segment 1.
segment1EndEnd of segment 1.
segment2StartStart of segment 2.
segment2EndEnd of segment 2.
[out]closestPointSegment1Closest point on segment 1.
[out]closestPointSegment2Closest point on segment 2.
epsilonThe minimum square distance where a line segment can be treated as a single point.

◆ IntersectRayAABB()

RayAABBIsectTypes AZ::Intersect::IntersectRayAABB ( const Vector3 rayStart,
const Vector3 dir,
const Vector3 dirRCP,
const Aabb aabb,
float &  tStart,
float &  tEnd,
Vector3 startNormal 
)

Intersect ray R(t) = rayStart + t*d against AABB a. When intersecting, return intersection distance tmin and point q of intersection.

Parameters
rayStartRay starting point
dirRay direction and length (dir = rayEnd - rayStart)
dirRCP1/dir (reciprocal direction - we cache this result very often so we don't need to compute it multiple times, otherwise just use dir.GetReciprocal())
aabbAxis aligned bounding box to intersect against
tStartTime on ray of the first intersection [0,1] or 0 if the ray starts inside the aabb - check the return value
tEndTime of the of the second intersection [0,1] (it can be > 1 if intersects after the rayEnd)
startNormalNormal at the start point.
Returns
RayAABBIsectTypes

◆ IntersectRayAABB2()

RayAABBIsectTypes AZ::Intersect::IntersectRayAABB2 ( const Vector3 rayStart,
const Vector3 dirRCP,
const Aabb aabb,
float &  start,
float &  end 
)

Intersect ray against AABB.

Parameters
rayStartRay starting point.
dirRay reciprocal direction.
aabbAxis aligned bounding box to intersect against.
startLength on ray of the first intersection.
endLength of the of the second intersection.
Returns
RayAABBIsectTypes In this faster version than IntersectRayAABB we return only ISECT_RAY_AABB_NONE and ISECT_RAY_AABB_ISECT. You can check yourself for that case.

◆ IntersectRayBox()

bool AZ::Intersect::IntersectRayBox ( const Vector3 rayOrigin,
const Vector3 rayDir,
const Vector3 boxCenter,
const Vector3 boxAxis1,
const Vector3 boxAxis2,
const Vector3 boxAxis3,
float  boxHalfExtent1,
float  boxHalfExtent2,
float  boxHalfExtent3,
float &  t 
)

Test intersection between a ray and an oriented box in 3D.

Parameters
rayOriginThe origin of the ray to test intersection with.
rayDirThe direction of the ray to test intersection with.
boxCenterThe position of the center of the box.
boxAxis1An axis along one dimension of the oriented box.
boxAxis2An axis along one dimension of the oriented box.
boxAxis3An axis along one dimension of the oriented box.
boxHalfExtent1The half extent of the box on the dimension of boxAxis1.
boxHalfExtent2The half extent of the box on the dimension of boxAxis2.
boxHalfExtent3The half extent of the box on the dimension of boxAxis3.
[out]tThe coefficient in the ray's explicit equation from which the intersecting point is calculated as "rayOrigin + t * rayDirection".
Returns
true if there is an intersection, false otherwise.

◆ IntersectRayCappedCylinder()

int AZ::Intersect::IntersectRayCappedCylinder ( const Vector3 rayOrigin,
const Vector3 rayDir,
const Vector3 cylinderEnd1,
const Vector3 cylinderDir,
float  cylinderHeight,
float  cylinderRadius,
float &  t1,
float &  t2 
)

If there is only one intersecting point, the coefficient is stored in t1.

Parameters
rayOriginThe origin of the ray to test.
rayDirThe direction of the ray to test. It has to be unit length.
cylinderEnd1The center of the circle on one end of the cylinder.
cylinderDirThe direction pointing from cylinderEnd1 to the other end of the cylinder. It has to be unit length.
cylinderHeightThe distance between two centers of the circles on two ends of the cylinder respectively.
[out]t1A possible coefficient in the ray's explicit equation from which an intersecting point is calculated as "rayOrigin + t1 * rayDir".
[out]t2A possible coefficient in the ray's explicit equation from which an intersecting point is calculated as "rayOrigin + t2 * rayDir".
Returns
The number of intersecting points.

◆ IntersectRayCone()

int AZ::Intersect::IntersectRayCone ( const Vector3 rayOrigin,
const Vector3 rayDir,
const Vector3 coneApex,
const Vector3 coneDir,
float  coneHeight,
float  coneBaseRadius,
float &  t1,
float &  t2 
)

If there is only one intersecting point, the coefficient is stored in t1.

Parameters
rayOriginThe origin of the ray to test.
rayDirThe direction of the ray to test. It has to be unit length.
coneApexThe apex of the cone.
coneDirThe unit-length direction from the apex to the base.
coneHeightThe height of the cone, from the apex to the base.
coneBaseRadiusThe radius of the cone base circle.
[out]t1A possible coefficient in the ray's explicit equation from which an intersecting point is calculated as "rayOrigin + t1 * rayDir".
[out]t2A possible coefficient in the ray's explicit equation from which an intersecting point is calculated as "rayOrigin + t2 * rayDir".
Returns
The number of intersecting points.

◆ IntersectRayDisk()

bool AZ::Intersect::IntersectRayDisk ( const Vector3 rayOrigin,
const Vector3 rayDir,
const Vector3 diskCenter,
const float  diskRadius,
const AZ::Vector3 diskNormal,
float &  t 
)

Intersect ray (rayStarty, rayDirNormalized) and disk (center, radius, normal)

Parameters
rayOriginThe origin of the ray to test.
rayDirThe direction of the ray to test. It has to be unit length.
diskCenterCenter point of the disk.
diskRadiusRadius of the disk.
diskNormalA normal perpendicular to the disk.
[out]tIf returning 1 (indicating a hit), this contains distance from rayOrigin along the normalized rayDir that the hit occured at.
Returns
False if not interesecting and true if intersecting

◆ IntersectRayObb()

bool AZ::Intersect::IntersectRayObb ( const Vector3 rayOrigin,
const Vector3 rayDir,
const Obb obb,
float &  t 
)

Test intersection between a ray and an OBB.

Parameters
rayOriginThe origin of the ray to test intersection with.
rayDirThe direction of the ray to test intersection with.
obbThe OBB to test for intersection with the ray.
[out]tThe coefficient in the ray's explicit equation from which the intersecting point is calculated as "rayOrigin + t * rayDirection".
Returns
True if there is an intersection, false otherwise.

◆ IntersectRayPlane()

int AZ::Intersect::IntersectRayPlane ( const Vector3 rayOrigin,
const Vector3 rayDir,
const Vector3 planePos,
const Vector3 planeNormal,
float &  t 
)

Test intersection between a ray and a plane in 3D.

Parameters
rayOriginThe origin of the ray to test intersection with.
rayDirThe direction of the ray to test intersection with.
planePosA point on the plane to test intersection with.
planeNormalThe normal of the plane to test intersection with.
[out]tThe coefficient in the ray's explicit equation from which the intersecting point is calculated as "rayOrigin + t * rayDirection".
Returns
The number of intersection point.

◆ IntersectRayQuad()

int AZ::Intersect::IntersectRayQuad ( const Vector3 rayOrigin,
const Vector3 rayDir,
const Vector3 vertexA,
const Vector3 vertexB,
const Vector3 vertexC,
const Vector3 vertexD,
float &  t 
)

Test intersection between a ray and a two-sided quadrilateral defined by four points in 3D. The four points that define the quadrilateral could be passed in with either counter clock-wise winding or clock-wise winding.

Parameters
rayOriginThe origin of the ray to test intersection with.
rayDirThe direction of the ray to test intersection with.
vertexAOne of the four points that define the quadrilateral.
vertexBOne of the four points that define the quadrilateral.
vertexCOne of the four points that define the quadrilateral.
vertexDOne of the four points that define the quadrilateral.
[out]tThe coefficient in the ray's explicit equation from which the intersecting point is calculated as "rayOrigin + t * rayDirection".
Returns
The number of intersection point.

◆ IntersectRaySphere()

AZ_MATH_INLINE SphereIsectTypes AZ::Intersect::IntersectRaySphere ( const Vector3 rayStart,
const Vector3 rayDirNormalized,
const Vector3 sphereCenter,
const float  sphereRadius,
float &  t 
)

Intersect ray (rayStart,rayDirNormalized) and sphere (sphereCenter,sphereRadius) IntersectRaySphereOrigin

Parameters
rayStartThe start of the ray.
rayDirNormalizedThe direction of the ray normalized.
sphereCenterThe center of the sphere.
sphereRadiusRadius of the sphere.
[out]tCoefficient in the ray's explicit equation from which an intersecting point is calculated as "rayOrigin + t1 * rayDir".
Returns
SphereIsectTypes

◆ IntersectRaySphereOrigin()

AZ_MATH_INLINE SphereIsectTypes AZ::Intersect::IntersectRaySphereOrigin ( const Vector3 rayStart,
const Vector3 rayDirNormalized,
const float  sphereRadius,
float &  t 
)

IntersectRaySphereOrigin return time t>=0 but not limited, so if you check a segment make sure t <= segmentLen.

Parameters
rayStartray start point.
rayDirNormalizedray direction normalized.
shereRadiusRadius of sphere at origin.
timeof closest intersection [0,+INF] in relation to the normalized direction.
Returns
SphereIsectTypes.

◆ IntersectSegmentCapsule()

CapsuleIsectTypes AZ::Intersect::IntersectSegmentCapsule ( const Vector3 sa,
const Vector3 dir,
const Vector3 p,
const Vector3 q,
const float  r,
float &  t 
)

This is a quick implementation of segment capsule based on segment cylinder IntersectSegmentCylinder segment sphere intersection. We can optimize it a lot once we fix the ray cylinder intersection.

Parameters
saThe beginning of the line segment.
dirThe direction and length of the segment.
pCenter point of side 1 capsule.
qCenter point of side 1 capsule.
rThe radius of the capsule.
[out]tProporition along line segment.
Returns
CapsuleIsectTypes

◆ IntersectSegmentCylinder()

CylinderIsectTypes AZ::Intersect::IntersectSegmentCylinder ( const Vector3 sa,
const Vector3 dir,
const Vector3 p,
const Vector3 q,
const float  r,
float &  t 
)

Reference: Real-Time Collision Detection - 5.3.7 Intersecting Ray or Segment Against Cylinder Intersect segment S(t)=sa+t(dir), 0<=t<=1 against cylinder specified by p, q and r.

Parameters
saThe initial point.
dirMagnitude and direction for sa.
pCenter point of side 1 cylinder.
qCenter point of side 2 cylinder.
rRadius of cylinder.
[out]tProporition along line segment.
Returns
CylinderIsectTypes

◆ IntersectSegmentPolyhedron()

bool AZ::Intersect::IntersectSegmentPolyhedron ( const Vector3 sa,
const Vector3 dir,
const Plane  p[],
int  numPlanes,
float &  tfirst,
float &  tlast,
int &  iFirstPlane,
int &  iLastPlane 
)

Intersect segment S(t)=A+t(B-A), 0<=t<=1 against convex polyhedron specified by the n halfspaces defined by the planes p[]. On exit tfirst and tlast define the intersection, if any.

Parameters
saThe beggining of the line segment.
dirThe direction and length of the segment.
pPlanes that compose a convex ponvex polyhedron.
numPlanesnumber of planes.
[out]tfirstProportion along the line segment where the line enters.
[out]tlastProportion along the line segment where the line exits.
[out]iFirstPlaneThe plane where the line enters.
[out]iLastPlaneThe plane where the line exits.
Returns
True if intersects else false.

◆ IntersectSegmentTriangle()

AZ_MATH_INLINE bool AZ::Intersect::IntersectSegmentTriangle ( const Vector3 p,
const Vector3 q,
const Vector3 a,
const Vector3 b,
const Vector3 c,
Vector3 normal,
float &  t 
)

Same as IntersectSegmentTriangleCCW without respecting the triangle (a,b,c) vertex order (i.e. double sided). This is a convenience method on top of the SegmentTriangleHitTester to make it easier to call the API in the single ray/triangle intersection use case.

Parameters
pSegment start point.
qSegment end point.
aTriangle vertex 1.
bTriangle vertex 2.
cTriangle vertex 3.
normalTriangle normal at the intersection point if segment intersects triangle.
tTime of intersection along the segment [0.0 (p), 1.0 (q)] if segment intersects triangle.
Returns
true if the segment intersects the triangle otherwise false.

◆ IntersectSegmentTriangleCCW()

AZ_MATH_INLINE bool AZ::Intersect::IntersectSegmentTriangleCCW ( const Vector3 p,
const Vector3 q,
const Vector3 a,
const Vector3 b,
const Vector3 c,
Vector3 normal,
float &  t 
)

Given a segment pq and a triangle abc (CCW), returns whether the segment intersects the triangle and if so, also returns the time of intersection along the segment and the triangle normal. This is a convenience method on top of the SegmentTriangleHitTester to make it easier to call the API in the single ray/triangle intersection use case.

Parameters
pSegment start point.
qSegment end point.
aTriangle vertex 1.
bTriangle vertex 2.
cTriangle vertex 3.
normalTriangle normal at the intersection point if segment intersects triangle.
tTime of intersection along the segment [0.0 (p), 1.0 (q)] if segment intersects triangle.
Returns
true if the segment intersects the triangle otherwise false.

◆ LineToPointDistance()

AZ_MATH_INLINE Vector3 AZ::Intersect::LineToPointDistance ( const Vector3 s1,
const Vector3 s2,
const Vector3 p,
float &  u 
)

LineToPointDistance computes the closest point to 'p' from a segment (s1,s2).

Parameters
s1Segment start point
s2Segment end point
pPoint to find the closest time to.
uTime (on the segment) for the shortest distance from 'p' to (s1,s2) [0.0f (s1),1.0f (s2)]
Returns
The closest point

◆ LineToPointDistanceTime()

AZ_MATH_INLINE float AZ::Intersect::LineToPointDistanceTime ( const Vector3 s1,
const Vector3 s21,
const Vector3 p 
)

LineToPointDistanceTime computes the time of the shortest distance from point 'p' to segment (s1,s2). To calculate the point of intersection: P = s1 + u (s2 - s1)

Parameters
s1Segment start point.
s2Segment end point.
pPoint to find the closest time to.
Returns
Time (on the segment) for the shortest distance from 'p' to (s1,s2) [0.0f (s1),1.0f (s2)]

◆ PointCylinder()

AZ_INLINE bool AZ::Intersect::PointCylinder ( const AZ::Vector3 baseCenterPoint,
const AZ::Vector3 axisVector,
float  axisLengthSquared,
float  radiusSquared,
const AZ::Vector3 testPoint 
)

This method checks if a point is inside a cylinder or outside it.

Parameters
baseCenterPointVector to the base of the cylinder.
axisVectorNon normalized vector from the base of the cylinder to the other end.
axisLengthSquaredsquare of length of "axisVector".
radiusSquaredsquare of cylinder radius.
testPointPoint to be tested.
Returns
boolean value indicating if the point is inside or not.

◆ PointSegmentDistanceSq()

float AZ::Intersect::PointSegmentDistanceSq ( const Vector3 point,
const Vector3 segmentStart,
const Vector3 segmentEnd 
)

Calculate the distance squared from the provided point to the closest point on segment segmentStart/segmentEnd.

Parameters
pointThe point to test
segmentStartThe start of the segment
segmentEndThe end of the segment
Returns
the distance squared from the point to the segment.

◆ PointSphere()

AZ_INLINE bool AZ::Intersect::PointSphere ( const Vector3 centerPosition,
float  radiusSquared,
const Vector3 testPoint 
)

This method checks if a point is inside a sphere or outside it.

Parameters
centerPositionPosition of the center of the sphere.
radiusSquaredsquare of sphere radius.
testPointPoint to be tested.
Returns
boolean value indicating if the point is inside or not.

◆ TestSegmentAABB()

AZ_MATH_INLINE bool AZ::Intersect::TestSegmentAABB ( const Vector3 p0,
const Vector3 p1,
const Aabb aabb 
)

Test if segment specified by points p0 and p1 intersects AABB. TestSegmentAABBOrigin.

Parameters
p0Segment start point.
p1Segment end point.
aabbBounded box to test against.
Returns
True if the segment and AABB intersect, otherwise false.

◆ TestSegmentAABBOrigin()

bool AZ::Intersect::TestSegmentAABBOrigin ( const Vector3 midPoint,
const Vector3 halfVector,
const Vector3 aabbExtends 
)

Test segment and aabb where the segment is defined by midpoint midPoint = (p1-p0) * 0.5f and half vector halfVector = p1 - midPoint. the aabb is at the origin and defined by half extents only.

Parameters
midPointMidpoint of a line segment.
halfVectorHalf vector of an aabb.
aabbExtendsThe extends of a bounded box.
Returns
True if the segment and AABB intersect, otherwise false