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/v0.7.0/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 |
|
inline |
Index operator to get the i^th vertex.
idx | The index of the desired vertex |
|
inline |
Returns the normal of the triangle (not normalized)
|
inline |
Returns the area of the triangle (3D specialization)
|
inline |
Returns the area of the triangle (2D specialization)
|
inline |
Returns the signed area of a 2D triangle.
The area is positive when the vertices are oriented counter-clockwise.
|
inline |
|
inline |
Returns the signed volume of a 2D triangle.
|
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
|
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.
|
inline |
Returns the physical coordinates of a barycentric point.
[in] | bary | Barycentric coordinates relative to this triangle |
|
inline |
Returns whether the triangle is degenerate.
|
inline |
Returns whether Point P is in the triangle for some 3d Triangle.
|
inline |
Computes the request angle corresponding to the given vertex ID.
[in] | idx | the index of the corresponding vertex |
|
inline |
Simple formatted print of a triangle instance.
os | The output stream to write to |
|
static |
|
static |