AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::primal::Tetrahedron< T, NDIMS > Class Template Reference

Represents a tetrahedral geometric shape defined by four points. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/v0.7.0/src/axom/primal/geometry/Tetrahedron.hpp>

Public Types

using PointType = Point< T, NDIMS >
 
using VectorType = Vector< T, NDIMS >
 
using SphereType = Sphere< T, NDIMS >
 

Public Member Functions

AXOM_HOST_DEVICE Tetrahedron ()
 Default constructor. Creates a degenerate tetrahedron. More...
 
AXOM_HOST_DEVICE Tetrahedron (const PointType &A, const PointType &B, const PointType &C, const PointType &D)
 Tetrahedron constructor from 4 points A,B,C,D. More...
 
AXOM_HOST_DEVICE PointTypeoperator[] (int idx)
 Index operator to get the i^th vertex. More...
 
AXOM_HOST_DEVICE const PointTypeoperator[] (int idx) const
 Index operator to get the i^th vertex. More...
 
AXOM_HOST_DEVICE bool degenerate (double eps=1.0e-12) const
 Returns whether the tetrahedron is degenerate. More...
 
Point< double, 4 > physToBarycentric (const PointType &p, bool skipNormalization=false) const
 Returns the barycentric coordinates of a point within a tetrahedron. More...
 
PointType baryToPhysical (const Point< double, 4 > &bary) const
 Returns the physical coordinates of a barycentric point. More...
 
std::ostream & print (std::ostream &os) const
 Simple formatted print of a tetrahedron instance. More...
 
AXOM_HOST_DEVICE double signedVolume () const
 Returns the signed volume of the tetrahedron. More...
 
AXOM_HOST_DEVICE double volume () const
 Returns the absolute (unsigned) volume of the tetrahedron. More...
 
template<int TDIM = NDIMS>
std::enable_if< TDIM==3, SphereType >::type circumsphere () const
 Returns the circumsphere (circumscribing sphere) of the tetrahedron. More...
 

Static Public Attributes

static constexpr int NUM_TET_VERTS = 4
 

Detailed Description

template<typename T, int NDIMS>
class axom::primal::Tetrahedron< T, NDIMS >

Represents a tetrahedral geometric shape defined by four points.

Template Parameters
Tthe coordinate type, e.g., double, float, etc.
NDIMSthe number of spatial dimensions

Member Typedef Documentation

◆ PointType

template<typename T, int NDIMS>
using axom::primal::Tetrahedron< T, NDIMS >::PointType = Point<T, NDIMS>

◆ VectorType

template<typename T, int NDIMS>
using axom::primal::Tetrahedron< T, NDIMS >::VectorType = Vector<T, NDIMS>

◆ SphereType

template<typename T, int NDIMS>
using axom::primal::Tetrahedron< T, NDIMS >::SphereType = Sphere<T, NDIMS>

Constructor & Destructor Documentation

◆ Tetrahedron() [1/2]

template<typename T, int NDIMS>
AXOM_HOST_DEVICE axom::primal::Tetrahedron< T, NDIMS >::Tetrahedron ( )
inline

Default constructor. Creates a degenerate tetrahedron.

References AXOM_HOST_DEVICE.

◆ Tetrahedron() [2/2]

template<typename T, int NDIMS>
AXOM_HOST_DEVICE axom::primal::Tetrahedron< T, NDIMS >::Tetrahedron ( const PointType A,
const PointType B,
const PointType C,
const PointType D 
)
inline

Tetrahedron constructor from 4 points A,B,C,D.

Parameters
[in]AVertex A of the tetrahedron
[in]BVertex B of the tetrahedron
[in]CVertex C of the tetrahedron
[in]DVertex D of the tetrahedron
Note
The orientation of the tetrahedron is determined from the scalar triple product of the vectors from B, C and D to A, respectively, i.e. \( dot(B-A, cross(C-A, D-A)) \).

Member Function Documentation

◆ operator[]() [1/2]

template<typename T, int NDIMS>
AXOM_HOST_DEVICE PointType& axom::primal::Tetrahedron< T, NDIMS >::operator[] ( int  idx)
inline

Index operator to get the i^th vertex.

Parameters
idxThe index of the desired vertex
Precondition
idx is 0, 1, 2, or 3

References SLIC_ASSERT.

◆ operator[]() [2/2]

template<typename T, int NDIMS>
AXOM_HOST_DEVICE const PointType& axom::primal::Tetrahedron< T, NDIMS >::operator[] ( int  idx) const
inline

Index operator to get the i^th vertex.

Parameters
idxThe index of the desired vertex
Precondition
idx is 0, 1, 2, or 3

References AXOM_HOST_DEVICE, and SLIC_ASSERT.

◆ degenerate()

template<typename T, int NDIMS>
AXOM_HOST_DEVICE bool axom::primal::Tetrahedron< T, NDIMS >::degenerate ( double  eps = 1.0e-12) const
inline

Returns whether the tetrahedron is degenerate.

Returns
true iff the tetrahedron is degenerate (has near zero volume)

References axom::utilities::isNearlyEqual().

◆ physToBarycentric()

template<typename T, int NDIMS>
Point<double, 4> axom::primal::Tetrahedron< T, NDIMS >::physToBarycentric ( const PointType p,
bool  skipNormalization = false 
) const
inline

Returns the barycentric coordinates of a point within a tetrahedron.

Parameters
[in]pThe point at which we want to compute barycentric coordinates
[in]skipNormalizationDetermines if the result should be normalized by the volume of the tetrahedron. One might want to skip this if they were only interested in the relative weights rather than their actual amounts
Postcondition
The barycentric coordinates sum to 1 when skipNormalization is false Otherwise, the sum of coordinates will be proportional to volume of the tetrahedron (Specifically, they should sum to the parallelpiped volume, which is 6x the volume).

References axom::primal::abs(), axom::primal::Point< T, NDIMS >::array(), axom::primal::Vector< T, NDIMS >::scalar_triple_product(), and axom::primal::NumericArray< T, SIZE >::sum().

◆ baryToPhysical()

template<typename T, int NDIMS>
PointType axom::primal::Tetrahedron< T, NDIMS >::baryToPhysical ( const Point< double, 4 > &  bary) const
inline

Returns the physical coordinates of a barycentric point.

Parameters
[in]baryBarycentric coordinates relative to this tetrahedron

References axom::primal::Point< T, NDIMS >::array(), axom::utilities::isNearlyEqual(), axom::primal::Tetrahedron< T, NDIMS >::NUM_TET_VERTS, and SLIC_CHECK_MSG.

◆ print()

template<typename T, int NDIMS>
std::ostream& axom::primal::Tetrahedron< T, NDIMS >::print ( std::ostream &  os) const
inline

Simple formatted print of a tetrahedron instance.

Parameters
osThe output stream to write to
Returns
A reference to the modified ostream

References AXOM_HOST_DEVICE.

◆ signedVolume()

template<typename T, int NDIMS>
AXOM_HOST_DEVICE double axom::primal::Tetrahedron< T, NDIMS >::signedVolume ( ) const
inline

Returns the signed volume of the tetrahedron.

See also
volume()

References AXOM_HOST_DEVICE.

◆ volume()

template<typename T, int NDIMS>
AXOM_HOST_DEVICE double axom::primal::Tetrahedron< T, NDIMS >::volume ( ) const
inline

Returns the absolute (unsigned) volume of the tetrahedron.

See also
signedVolume()

References axom::utilities::abs(), and axom::primal::Tetrahedron< T, NDIMS >::signedVolume().

◆ circumsphere()

template<typename T, int NDIMS>
template<int TDIM = NDIMS>
std::enable_if<TDIM == 3, SphereType>::type axom::primal::Tetrahedron< T, NDIMS >::circumsphere ( ) const
inline

Returns the circumsphere (circumscribing sphere) of the tetrahedron.

Derived from formula on https://mathworld.wolfram.com/Circumsphere.html but uses observation that radius can be derived from distance to a vertex

Note
This function is only available for 3D tetrahedra in 3D

References AXOM_HOST_DEVICE, and axom::primal::Vector< T, NDIMS >::scalar_triple_product().

Member Data Documentation

◆ NUM_TET_VERTS

template<typename T, int NDIMS>
constexpr int axom::primal::Tetrahedron< T, NDIMS >::NUM_TET_VERTS = 4
static

The documentation for this class was generated from the following file: