PhysicsBasedAnimationToolkit 0.0.10
Cross-platform C++20 library of algorithms and data structures commonly used in computer graphics research on physically-based simulation.
Loading...
Searching...
No Matches
pbat::geometry::IntersectionQueries Namespace Reference

This namespace contains functions to answer intersection queries. More...

Functions

template<mini::CMatrix TMatrixAP, mini::CMatrix TMatrixAB, mini::CMatrix TMatrixAC>
PBAT_HOST_DEVICE auto TriangleBarycentricCoordinates (TMatrixAP const &AP, TMatrixAB const &AB, TMatrixAC const &AC) -> mini::SMatrix< typename TMatrixAP::ScalarType, 3, 1 >
 Computes the barycentric coordinates of point P with respect to the triangle spanned by vertices A, B, and C.
 
template<mini::CMatrix TMatrixP, mini::CMatrix TMatrixA, mini::CMatrix TMatrixB, mini::CMatrix TMatrixC>
PBAT_HOST_DEVICE auto TriangleBarycentricCoordinates (TMatrixP const &P, TMatrixA const &A, TMatrixB const &B, TMatrixC const &C) -> mini::SVector< typename TMatrixP::ScalarType, 3 >
 Computes the barycentric coordinates of point P with respect to the triangle spanned by vertices A, B, and C.
 
template<mini::CMatrix TMatrixL1, mini::CMatrix TMatrixU1, mini::CMatrix TMatrixL2, mini::CMatrix TMatrixU2>
PBAT_HOST_DEVICE auto AxisAlignedBoundingBoxes (TMatrixL1 const &L1, TMatrixU1 const &U1, TMatrixL2 const &L2, TMatrixU2 const &U2) -> mini::SMatrix< typename TMatrixL1::ScalarType, TMatrixL1::Rows, 2 >
 Computes the intersection volume between 2 axis aligned bounding boxes.
 
template<mini::CMatrix TMatrixP, mini::CMatrix TMatrixQ, mini::CMatrix TMatrixC>
PBAT_HOST_DEVICE auto LineSegmentSphere (TMatrixP const &P, TMatrixQ const &Q, TMatrixC const &C, typename TMatrixC::ScalarType R) -> std::optional< mini::SVector< typename TMatrixP::ScalarType, TMatrixP::kRows > >
 Computes the intersection point, if any, between a line segment PQ and a sphere (C,r).
 
template<mini::CMatrix TMatrixP, mini::CMatrix TMatrixQ, mini::CMatrix TMatrixA, mini::CMatrix TMatrixB, mini::CMatrix TMatrixC>
PBAT_HOST_DEVICE auto LineSegmentPlane3D (TMatrixP const &P, TMatrixQ const &Q, TMatrixA const &A, TMatrixB const &B, TMatrixC const &C) -> std::optional< mini::SVector< typename TMatrixP::ScalarType, TMatrixP::kRows > >
 Computes the intersection point, if any, between a line including points P,Q and the plane spanned by triangle ABC, in 3D.
 
template<mini::CMatrix TMatrixP, mini::CMatrix TMatrixQ, mini::CMatrix TMatrixN>
PBAT_HOST_DEVICE auto LineSegmentPlane3D (TMatrixP const &P, TMatrixQ const &Q, TMatrixN const &n, typename TMatrixN::ScalarType d) -> std::optional< mini::SVector< typename TMatrixP::ScalarType, TMatrixP::kRows > >
 Computes the intersection point, if any, between a line including points P,Q and the plane (n,d), in 3D.
 
template<mini::CMatrix TMatrixP, mini::CMatrix TMatrixQ, mini::CMatrix TMatrixA, mini::CMatrix TMatrixB, mini::CMatrix TMatrixC>
PBAT_HOST_DEVICE auto UvwLineTriangle3D (TMatrixP const &P, TMatrixQ const &Q, TMatrixA const &A, TMatrixB const &B, TMatrixC const &C) -> std::optional< mini::SVector< typename TMatrixP::ScalarType, 3 > >
 Computes the intersection point, if any, between a line including points P,Q and a triangle ABC, in 3D.
 
template<mini::CMatrix TMatrixP, mini::CMatrix TMatrixQ, mini::CMatrix TMatrixA, mini::CMatrix TMatrixB, mini::CMatrix TMatrixC>
PBAT_HOST_DEVICE auto UvwLineSegmentTriangle3D (TMatrixP const &P, TMatrixQ const &Q, TMatrixA const &A, TMatrixB const &B, TMatrixC const &C) -> std::optional< mini::SVector< typename TMatrixP::ScalarType, 4 > >
 Computes the intersection point, if any, between a line segment delimited by points P,Q and a triangle ABC, in 3D.
 
template<mini::CMatrix TMatrixA1, mini::CMatrix TMatrixB1, mini::CMatrix TMatrixC1, mini::CMatrix TMatrixA2, mini::CMatrix TMatrixB2, mini::CMatrix TMatrixC2>
PBAT_HOST_DEVICE auto UvwTriangles3D (TMatrixA1 const &A1, TMatrixB1 const &B1, TMatrixC1 const &C1, TMatrixA2 const &A2, TMatrixB2 const &B2, TMatrixC2 const &C2) -> std::array< std::optional< mini::SVector< typename TMatrixA1::ScalarType, 3 > >, 6u >
 Computes intersection points between 3 edges (as line segments) of triangle A1B1C1 and triangle A2B2C2, and intersection points between 3 edges (as line segments) of triangle A2B2C2 and triangle A1B1C1, in 3D.
 

Detailed Description

This namespace contains functions to answer intersection queries.

Function Documentation

◆ AxisAlignedBoundingBoxes()

template<mini::CMatrix TMatrixL1, mini::CMatrix TMatrixU1, mini::CMatrix TMatrixL2, mini::CMatrix TMatrixU2>
PBAT_HOST_DEVICE auto pbat::geometry::IntersectionQueries::AxisAlignedBoundingBoxes ( TMatrixL1 const & L1,
TMatrixU1 const & U1,
TMatrixL2 const & L2,
TMatrixU2 const & U2 ) -> mini::SMatrix<typename TMatrixL1::ScalarType, TMatrixL1::Rows, 2>

Computes the intersection volume between 2 axis aligned bounding boxes.

Template Parameters
TMatrixL1Matrix type of the lower bound of AABB 1
TMatrixU1Matrix type of the upper bound of AABB 1
TMatrixL2Matrix type of the lower bound of AABB 2
TMatrixU2Matrix type of the upper bound of AABB 2
Parameters
L1The lower bound of AABB 1
U1The upper bound of AABB 1
L2The lower bound of AABB 2
U2The upper bound of AABB 2
Returns
The intersection volume between the 2 AABBs

◆ LineSegmentPlane3D() [1/2]

template<mini::CMatrix TMatrixP, mini::CMatrix TMatrixQ, mini::CMatrix TMatrixA, mini::CMatrix TMatrixB, mini::CMatrix TMatrixC>
PBAT_HOST_DEVICE auto pbat::geometry::IntersectionQueries::LineSegmentPlane3D ( TMatrixP const & P,
TMatrixQ const & Q,
TMatrixA const & A,
TMatrixB const & B,
TMatrixC const & C ) -> std::optional<mini::SVector<typename TMatrixP::ScalarType, TMatrixP::kRows>>

Computes the intersection point, if any, between a line including points P,Q and the plane spanned by triangle ABC, in 3D.

Template Parameters
TMatrixPMatrix type of the point P
TMatrixQMatrix type of the point Q
TMatrixAMatrix type of the vertex A
TMatrixBMatrix type of the vertex B
TMatrixCMatrix type of the vertex C
Parameters
PThe start point of the line
QThe end point of the line
AVertex A of the triangle
BVertex B of the triangle
CVertex C of the triangle
Returns
The intersection point, if any

◆ LineSegmentPlane3D() [2/2]

template<mini::CMatrix TMatrixP, mini::CMatrix TMatrixQ, mini::CMatrix TMatrixN>
PBAT_HOST_DEVICE auto pbat::geometry::IntersectionQueries::LineSegmentPlane3D ( TMatrixP const & P,
TMatrixQ const & Q,
TMatrixN const & n,
typename TMatrixN::ScalarType d ) -> std::optional<mini::SVector<typename TMatrixP::ScalarType, TMatrixP::kRows>>

Computes the intersection point, if any, between a line including points P,Q and the plane (n,d), in 3D.

Template Parameters
TMatrixPMatrix type of the point P
TMatrixQMatrix type of the point Q
TMatrixNMatrix type of the normal vector of the plane
Parameters
PThe start point of the line
QThe end point of the line
nThe normal vector of the plane
dThe distance from the origin to the plane
Returns
The intersection point, if any

◆ LineSegmentSphere()

template<mini::CMatrix TMatrixP, mini::CMatrix TMatrixQ, mini::CMatrix TMatrixC>
PBAT_HOST_DEVICE auto pbat::geometry::IntersectionQueries::LineSegmentSphere ( TMatrixP const & P,
TMatrixQ const & Q,
TMatrixC const & C,
typename TMatrixC::ScalarType R ) -> std::optional<mini::SVector<typename TMatrixP::ScalarType, TMatrixP::kRows>>

Computes the intersection point, if any, between a line segment PQ and a sphere (C,r).

If there are 2 intersection points, returns the one closest to P along PQ.

Parameters
PThe start point of the line segment
QThe end point of the line segment
CThe center of the sphere
RThe radius of the sphere
Returns
The intersection point, if any

◆ TriangleBarycentricCoordinates() [1/2]

template<mini::CMatrix TMatrixAP, mini::CMatrix TMatrixAB, mini::CMatrix TMatrixAC>
PBAT_HOST_DEVICE auto pbat::geometry::IntersectionQueries::TriangleBarycentricCoordinates ( TMatrixAP const & AP,
TMatrixAB const & AB,
TMatrixAC const & AC ) -> mini::SMatrix<typename TMatrixAP::ScalarType, 3, 1>

Computes the barycentric coordinates of point P with respect to the triangle spanned by vertices A, B, and C.

Template Parameters
TMatrixAPMatrix type of the vector from A to P
TMatrixABMatrix type of the vector from A to B
TMatrixACMatrix type of the vector from A to C
Parameters
APThe vector from A to P
ABThe vector from A to B
ACThe vector from A to C
Returns
The barycentric coordinates of P with respect to the triangle ABC
Precondition
AP, AB, and AC are coplanar

◆ TriangleBarycentricCoordinates() [2/2]

template<mini::CMatrix TMatrixP, mini::CMatrix TMatrixA, mini::CMatrix TMatrixB, mini::CMatrix TMatrixC>
PBAT_HOST_DEVICE auto pbat::geometry::IntersectionQueries::TriangleBarycentricCoordinates ( TMatrixP const & P,
TMatrixA const & A,
TMatrixB const & B,
TMatrixC const & C ) -> mini::SVector<typename TMatrixP::ScalarType, 3>

Computes the barycentric coordinates of point P with respect to the triangle spanned by vertices A, B, and C.

Template Parameters
TMatrixPMatrix type of the point P
TMatrixAMatrix type of the vertex A
TMatrixBMatrix type of the vertex B
TMatrixCMatrix type of the vertex C
Parameters
PPoint from which to compute barycentric coordinates.
AVertex A of the triangle
BVertex B of the triangle
CVertex C of the triangle
Returns
The barycentric coordinates of P with respect to the triangle ABC
Precondition
P is in the plane spanned by triangle ABC.

◆ UvwLineSegmentTriangle3D()

template<mini::CMatrix TMatrixP, mini::CMatrix TMatrixQ, mini::CMatrix TMatrixA, mini::CMatrix TMatrixB, mini::CMatrix TMatrixC>
PBAT_HOST_DEVICE auto pbat::geometry::IntersectionQueries::UvwLineSegmentTriangle3D ( TMatrixP const & P,
TMatrixQ const & Q,
TMatrixA const & A,
TMatrixB const & B,
TMatrixC const & C ) -> std::optional<mini::SVector<typename TMatrixP::ScalarType, 4>>

Computes the intersection point, if any, between a line segment delimited by points P,Q and a triangle ABC, in 3D.

Template Parameters
TMatrixPMatrix type of the point P
TMatrixQMatrix type of the point Q
TMatrixAMatrix type of the vertex A
TMatrixBMatrix type of the vertex B
TMatrixCMatrix type of the vertex C
Parameters
PThe start point of the line segment
QThe end point of the line segment
AVertex A of the triangle
BVertex B of the triangle
CVertex C of the triangle
Returns
The intersection point as a 4-vector, if any, where the last 3 elements are the barycentric coordinates of the intersection point with respect to the triangle ABC, and the first element is the barycentric coordinate of the intersection point with respect to line segment PQ

◆ UvwLineTriangle3D()

template<mini::CMatrix TMatrixP, mini::CMatrix TMatrixQ, mini::CMatrix TMatrixA, mini::CMatrix TMatrixB, mini::CMatrix TMatrixC>
PBAT_HOST_DEVICE auto pbat::geometry::IntersectionQueries::UvwLineTriangle3D ( TMatrixP const & P,
TMatrixQ const & Q,
TMatrixA const & A,
TMatrixB const & B,
TMatrixC const & C ) -> std::optional<mini::SVector<typename TMatrixP::ScalarType, 3>>

Computes the intersection point, if any, between a line including points P,Q and a triangle ABC, in 3D.

Template Parameters
TMatrixPMatrix type of the point P
TMatrixQMatrix type of the point Q
TMatrixAMatrix type of the vertex A
TMatrixBMatrix type of the vertex B
TMatrixCMatrix type of the vertex C
Parameters
PThe start point of the line
QThe end point of the line
AVertex A of the triangle
BVertex B of the triangle
CVertex C of the triangle
Returns
The intersection point, if any

See [5] section 5.3.4

◆ UvwTriangles3D()

template<mini::CMatrix TMatrixA1, mini::CMatrix TMatrixB1, mini::CMatrix TMatrixC1, mini::CMatrix TMatrixA2, mini::CMatrix TMatrixB2, mini::CMatrix TMatrixC2>
PBAT_HOST_DEVICE auto pbat::geometry::IntersectionQueries::UvwTriangles3D ( TMatrixA1 const & A1,
TMatrixB1 const & B1,
TMatrixC1 const & C1,
TMatrixA2 const & A2,
TMatrixB2 const & B2,
TMatrixC2 const & C2 ) -> std::array<std::optional<mini::SVector<typename TMatrixA1::ScalarType, 3>>, 6u>

Computes intersection points between 3 edges (as line segments) of triangle A1B1C1 and triangle A2B2C2, and intersection points between 3 edges (as line segments) of triangle A2B2C2 and triangle A1B1C1, in 3D.

Template Parameters
TMatrixA1Matrix type of the vertex A1 of triangle 1
TMatrixB1Matrix type of the vertex B1 of triangle 1
TMatrixC1Matrix type of the vertex C1 of triangle 1
TMatrixA2Matrix type of the vertex A2 of triangle 2
TMatrixB2Matrix type of the vertex B2 of triangle 2
TMatrixC2Matrix type of the vertex C2 of triangle 2
Parameters
A1Vertex A of triangle 1
B1Vertex B of triangle 1
C1Vertex C of triangle 1
A2Vertex A of triangle 2
B2Vertex B of triangle 2
C2Vertex C of triangle 2
Returns
The intersection points, if any