Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
ClosestPoint Namespace Reference

Helper utils to find the closest point to a line segment, triangle or tetrahedron. More...

Functions

bool GetBaryCentricCoordinates (Vec3Arg inA, Vec3Arg inB, float &outU, float &outV)
 
bool GetBaryCentricCoordinates (Vec3Arg inA, Vec3Arg inB, Vec3Arg inC, float &outU, float &outV, float &outW)
 
Vec3 GetClosestPointOnLine (Vec3Arg inA, Vec3Arg inB, uint32 &outSet)
 
template<bool MustIncludeC = false>
Vec3 GetClosestPointOnTriangle (Vec3Arg inA, Vec3Arg inB, Vec3Arg inC, uint32 &outSet)
 
bool OriginOutsideOfPlane (Vec3Arg inA, Vec3Arg inB, Vec3Arg inC, Vec3Arg inD)
 Check if the origin is outside the plane of triangle (inA, inB, inC). inD specifies the front side of the plane. More...
 
UVec4 OriginOutsideOfTetrahedronPlanes (Vec3Arg inA, Vec3Arg inB, Vec3Arg inC, Vec3Arg inD)
 
template<bool MustIncludeD = false>
Vec3 GetClosestPointOnTetrahedron (Vec3Arg inA, Vec3Arg inB, Vec3Arg inC, Vec3Arg inD, uint32 &outSet)
 

Detailed Description

Helper utils to find the closest point to a line segment, triangle or tetrahedron.

Function Documentation

◆ GetBaryCentricCoordinates() [1/2]

bool ClosestPoint::GetBaryCentricCoordinates ( Vec3Arg  inA,
Vec3Arg  inB,
float &  outU,
float &  outV 
)
inline

Compute barycentric coordinates of closest point to origin for infinite line defined by (inA, inB) Point can then be computed as inA * outU + inB * outV Returns false if the points inA, inB do not form a line (are at the same point)

◆ GetBaryCentricCoordinates() [2/2]

bool ClosestPoint::GetBaryCentricCoordinates ( Vec3Arg  inA,
Vec3Arg  inB,
Vec3Arg  inC,
float &  outU,
float &  outV,
float &  outW 
)
inline

Compute barycentric coordinates of closest point to origin for plane defined by (inA, inB, inC) Point can then be computed as inA * outU + inB * outV + inC * outW Returns false if the points inA, inB, inC do not form a plane (are on the same line or at the same point)

◆ GetClosestPointOnLine()

Vec3 ClosestPoint::GetClosestPointOnLine ( Vec3Arg  inA,
Vec3Arg  inB,
uint32 outSet 
)
inline

Get the closest point to the origin of line (inA, inB) outSet describes which features are closest: 1 = a, 2 = b, 3 = line segment ab

◆ GetClosestPointOnTetrahedron()

template<bool MustIncludeD = false>
Vec3 ClosestPoint::GetClosestPointOnTetrahedron ( Vec3Arg  inA,
Vec3Arg  inB,
Vec3Arg  inC,
Vec3Arg  inD,
uint32 outSet 
)
inline

Get the closest point between tetrahedron (inA, inB, inC, inD) to the origin outSet specifies which feature was closest, 1 = a, 2 = b, 4 = c, 8 = d. Edges have 2 bits set, triangles 3 and if the point is in the interior 4 bits are set. If MustIncludeD is true, the function assumes that D is part of the closest feature (vertex, edge, face, tetrahedron) and does less work, if the assumption is not true then a closest point to the other features is returned.

◆ GetClosestPointOnTriangle()

template<bool MustIncludeC = false>
Vec3 ClosestPoint::GetClosestPointOnTriangle ( Vec3Arg  inA,
Vec3Arg  inB,
Vec3Arg  inC,
uint32 outSet 
)
inline

Get the closest point to the origin of triangle (inA, inB, inC) outSet describes which features are closest: 1 = a, 2 = b, 4 = c, 5 = line segment ac, 7 = triangle interior etc. If MustIncludeC is true, the function assumes that C is part of the closest feature (vertex, edge, face) and does less work, if the assumption is not true then a closest point to the other features is returned.

◆ OriginOutsideOfPlane()

bool ClosestPoint::OriginOutsideOfPlane ( Vec3Arg  inA,
Vec3Arg  inB,
Vec3Arg  inC,
Vec3Arg  inD 
)
inline

Check if the origin is outside the plane of triangle (inA, inB, inC). inD specifies the front side of the plane.

◆ OriginOutsideOfTetrahedronPlanes()

UVec4 ClosestPoint::OriginOutsideOfTetrahedronPlanes ( Vec3Arg  inA,
Vec3Arg  inB,
Vec3Arg  inC,
Vec3Arg  inD 
)
inline

Returns for each of the planes of the tetrahedron if the origin is inside it Roughly equivalent to: [OriginOutsideOfPlane(inA, inB, inC, inD), OriginOutsideOfPlane(inA, inC, inD, inB), OriginOutsideOfPlane(inA, inD, inB, inC), OriginOutsideOfPlane(inB, inD, inC, inA)]