AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
Represents a triangular geometric shape defined by three points. More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/latest/src/axom/primal/geometry/Triangle.hpp>
Public Types | |
using | PointType = Point< T, NDIMS > |
using | VectorType = Vector< T, NDIMS > |
using | SphereType = Sphere< T, NDIMS > |
Public Member Functions | |
AXOM_HOST_DEVICE | Triangle () |
Default constructor. Creates a degenerate triangle. More... | |
AXOM_HOST_DEVICE | Triangle (const PointType &A, const PointType &B, const PointType &C) |
Custom Constructor. Creates a triangle from the 3 points A,B,C. More... | |
AXOM_HOST_DEVICE PointType & | operator[] (int idx) |
Index operator to get the i^th vertex. More... | |
AXOM_HOST_DEVICE const PointType & | operator[] (int idx) const |
Index operator to get the i^th vertex. More... | |
template<int TDIM = NDIMS> | |
AXOM_HOST_DEVICE std::enable_if< TDIM==3, VectorType >::type | normal () const |
Returns the normal of the triangle (not normalized) More... | |
template<int TDIM = NDIMS> | |
AXOM_HOST_DEVICE std::enable_if< TDIM==3, double >::type | area () const |
Returns the area of the triangle (3D specialization) More... | |
template<int TDIM = NDIMS> | |
AXOM_HOST_DEVICE std::enable_if< TDIM==2, double >::type | area () const |
Returns the area of the triangle (2D specialization) More... | |
template<int TDIM = NDIMS> | |
AXOM_HOST_DEVICE std::enable_if< TDIM==2, double >::type | signedArea () const |
Returns the signed area of a 2D triangle. More... | |
AXOM_HOST_DEVICE double | volume () const |
Returns the volume of the triangle (synonym for area()) More... | |
template<int TDIM = NDIMS> | |
AXOM_HOST_DEVICE std::enable_if< TDIM==2, double >::type | signedVolume () const |
Returns the signed volume of a 2D triangle. More... | |
template<int TDIM = NDIMS> | |
std::enable_if< TDIM==2, SphereType >::type | circumsphere () const |
Returns the circumsphere (circumscribing circle) of the triangle. More... | |
Point< double, 3 > | physToBarycentric (const PointType &p, bool skipNormalization=false) const |
Returns the barycentric coordinates of a point within a triangle. More... | |
PointType | baryToPhysical (const Point< double, 3 > &bary) const |
Returns the physical coordinates of a barycentric point. More... | |
AXOM_HOST_DEVICE bool | degenerate (double eps=1.0e-12) const |
Returns whether the triangle is degenerate. More... | |
bool | checkInTriangle (const PointType &p, double eps=1e-8) const |
Returns whether Point P is in the triangle for some 3d Triangle. More... | |
AXOM_HOST_DEVICE double | angle (int idx) const |
Computes the request angle corresponding to the given vertex ID. More... | |
std::ostream & | print (std::ostream &os) const |
Simple formatted print of a triangle instance. More... | |
Static Public Attributes | |
static constexpr int | DIM = NDIMS |
static constexpr int | NUM_TRI_VERTS = 3 |
Represents a triangular geometric shape defined by three points.
T | the coordinate type, e.g., double, float, etc. |
NDIMS | the number of dimensions |
using axom::primal::Triangle< T, NDIMS >::PointType = Point<T, NDIMS> |
using axom::primal::Triangle< T, NDIMS >::VectorType = Vector<T, NDIMS> |
using axom::primal::Triangle< T, NDIMS >::SphereType = Sphere<T, NDIMS> |
|
inline |
Default constructor. Creates a degenerate triangle.
|
inline |
Custom Constructor. Creates a triangle from the 3 points A,B,C.
[in] | A | point instance corresponding to vertex A of the triangle. |
[in] | B | point instance corresponding to vertex B of the triangle. |
[in] | C | point instance corresponding to vertex C of the triangle. |
|
inline |
Index operator to get the i^th vertex.
idx | The index of the desired vertex |
References axom::primal::Triangle< T, NDIMS >::NUM_TRI_VERTS, and SLIC_ASSERT.
|
inline |
Index operator to get the i^th vertex.
idx | The index of the desired vertex |
References axom::primal::Triangle< T, NDIMS >::NUM_TRI_VERTS, and SLIC_ASSERT.
|
inline |
Returns the normal of the triangle (not normalized)
References axom::primal::Vector< T, NDIMS >::cross_product().
|
inline |
Returns the area of the triangle (3D specialization)
References axom::primal::Triangle< T, NDIMS >::normal().
|
inline |
Returns the area of the triangle (2D specialization)
References axom::utilities::abs(), and axom::primal::Triangle< T, NDIMS >::signedArea().
|
inline |
Returns the signed area of a 2D triangle.
The area is positive when the vertices are oriented counter-clockwise.
References axom::numerics::determinant().
|
inline |
Returns the volume of the triangle (synonym for area())
References axom::primal::Triangle< T, NDIMS >::area().
|
inline |
Returns the signed volume of a 2D triangle.
References axom::primal::Triangle< T, NDIMS >::signedArea().
|
inline |
Returns the circumsphere (circumscribing circle) of the triangle.
Derived from formula on https://mathworld.wolfram.com/Circumcircle.html but uses observation that radius can be derived from distance to a vertex
References axom::numerics::determinant().
|
inline |
Returns the barycentric coordinates of a point within a triangle.
[in] | p | The point at which we want to compute barycentric coordinates |
[in] | skipNormalization | Determines if the result should be normalized by the area of the triangle. One might want to skip this if they were only interested in the relative weights rather than their actual amounts |
Algorithm adapted from Real Time Collision Detection by Christer Ericson.
References axom::primal::abs(), axom::primal::Triangle< T, NDIMS >::area(), axom::primal::Vector< T, NDIMS >::cross_product(), axom::primal::Triangle< T, NDIMS >::DIM, axom::utilities::isNearlyEqual(), and SLIC_CHECK.
|
inline |
Returns the physical coordinates of a barycentric point.
[in] | bary | Barycentric coordinates relative to this triangle |
References axom::primal::Point< T, NDIMS >::array(), axom::utilities::isNearlyEqual(), axom::primal::Triangle< T, NDIMS >::NUM_TRI_VERTS, and SLIC_CHECK_MSG.
|
inline |
Returns whether the triangle is degenerate.
References axom::primal::Triangle< T, NDIMS >::area(), and axom::utilities::isNearlyEqual().
|
inline |
Returns whether Point P is in the triangle for some 3d Triangle.
References axom::utilities::isNearlyEqual(), and axom::primal::Triangle< T, NDIMS >::physToBarycentric().
|
inline |
Computes the request angle corresponding to the given vertex ID.
[in] | idx | the index of the corresponding vertex |
References axom::utilities::clampVal(), axom::numerics::dot_product(), and SLIC_ASSERT.
|
inline |
Simple formatted print of a triangle instance.
os | The output stream to write to |
|
staticconstexpr |
|
staticconstexpr |