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

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

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/develop/src/axom/primal/geometry/Quadrilateral.hpp>

Public Types

using PointType = Point< T, NDIMS >
 
using TriangleType = Triangle< T, NDIMS >
 

Public Member Functions

 Quadrilateral ()=default
 Default constructor. Creates a degenerate quadrilateral. More...
 
AXOM_HOST_DEVICE Quadrilateral (const PointType &A, const PointType &B, const PointType &C, const PointType &D)
 Custom Constructor. Creates a quadrilateral from the 4 points A, B, C, and D. More...
 
AXOM_HOST_DEVICE Quadrilateral (std::initializer_list< PointType > pts)
 Quadrilateral constructor from an initializer list of Points. More...
 
AXOM_HOST_DEVICE Quadrilateral (const axom::ArrayView< PointType > pts)
 Quadrilateral constructor from an Array of Points. 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...
 
template<int TDIM = NDIMS>
AXOM_HOST_DEVICE std::enable_if< TDIM==2, double >::type area () const
 Returns the area of the quadrilateral (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 quadrilateral. More...
 
AXOM_HOST_DEVICE double volume () const
 Returns the volume of the quadrilateral (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 quadrilateral (synonym for signedArea()) More...
 
std::ostream & print (std::ostream &os) const
 Simple formatted print of a quadrilateral instance. More...
 

Static Public Attributes

static constexpr int DIM = NDIMS
 
static constexpr int NUM_QUAD_VERTS = 4
 

Detailed Description

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

Represents a quadrilateral geometric shape defined by four points.

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

There are four vertices in the quadrilateral, labeled A through D as the constructor's arguments. They are accessible using the square-brackets operator, with A being index 0, B index 1, C index 2, and D index 3.

Here's a diagram showing a square with the labeled vertices.

*
* D +---------+ C       +y
*   |         |         
*   |         |          ^
*   |         |          |
*   |         |          |
* A +---------+ B        -----> +x
*
* 

Member Typedef Documentation

◆ PointType

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

◆ TriangleType

template<typename T , int NDIMS>
using axom::primal::Quadrilateral< T, NDIMS >::TriangleType = Triangle<T, NDIMS>

Constructor & Destructor Documentation

◆ Quadrilateral() [1/4]

template<typename T , int NDIMS>
axom::primal::Quadrilateral< T, NDIMS >::Quadrilateral ( )
default

Default constructor. Creates a degenerate quadrilateral.

◆ Quadrilateral() [2/4]

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

Custom Constructor. Creates a quadrilateral from the 4 points A, B, C, and D.

Parameters
[in]Apoint corresponding to vertex A of the quadrilateral.
[in]Bpoint corresponding to vertex B of the quadrilateral.
[in]Cpoint corresponding to vertex C of the quadrilateral.
[in]Dpoint corresponding to vertex D of the quadrilateral.

◆ Quadrilateral() [3/4]

template<typename T , int NDIMS>
AXOM_HOST_DEVICE axom::primal::Quadrilateral< T, NDIMS >::Quadrilateral ( std::initializer_list< PointType pts)
inlineexplicit

Quadrilateral constructor from an initializer list of Points.

Parameters
[in]ptsan initializer list containing 4 Points

References axom::primal::Quadrilateral< T, NDIMS >::NUM_QUAD_VERTS, and SLIC_ASSERT.

◆ Quadrilateral() [4/4]

template<typename T , int NDIMS>
AXOM_HOST_DEVICE axom::primal::Quadrilateral< T, NDIMS >::Quadrilateral ( const axom::ArrayView< PointType pts)
inlineexplicit

Quadrilateral constructor from an Array of Points.

Parameters
[in]ptsAn ArrayView containing 4 Points.

References axom::primal::Quadrilateral< T, NDIMS >::NUM_QUAD_VERTS, axom::ArrayView< T, DIM, SPACE >::size(), and SLIC_ASSERT.

Member Function Documentation

◆ operator[]() [1/2]

template<typename T , int NDIMS>
AXOM_HOST_DEVICE PointType& axom::primal::Quadrilateral< 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 axom::primal::Quadrilateral< T, NDIMS >::NUM_QUAD_VERTS, and SLIC_ASSERT.

◆ operator[]() [2/2]

template<typename T , int NDIMS>
AXOM_HOST_DEVICE const PointType& axom::primal::Quadrilateral< 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::primal::Quadrilateral< T, NDIMS >::NUM_QUAD_VERTS, and SLIC_ASSERT.

◆ area()

template<typename T , int NDIMS>
template<int TDIM = NDIMS>
AXOM_HOST_DEVICE std::enable_if<TDIM == 2, double>::type axom::primal::Quadrilateral< T, NDIMS >::area ( ) const
inline

Returns the area of the quadrilateral (2D specialization)

References axom::utilities::abs(), and axom::primal::Quadrilateral< T, NDIMS >::signedArea().

◆ signedArea()

template<typename T , int NDIMS>
template<int TDIM = NDIMS>
AXOM_HOST_DEVICE std::enable_if<TDIM == 2, double>::type axom::primal::Quadrilateral< T, NDIMS >::signedArea ( ) const
inline

Returns the signed area of a 2D quadrilateral.

The area is positive when the vertices are oriented counter-clockwise.

Note
This function is only available for quadrilaterals in 2D since signed areas don't make sense for 3D quadrilaterals

Compute the signed area by dividing the quadrilateral into two triangles as shown below and summing their signed area

*
* D +----+ C       +y
*   |   /|         
*   |  / |          ^
*   | /  |          |
*   |/   |          |
* A +----+ B        -----> +x
*
* 

◆ volume()

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

Returns the volume of the quadrilateral (synonym for area())

See also
area()

References axom::primal::Quadrilateral< T, NDIMS >::area().

◆ signedVolume()

template<typename T , int NDIMS>
template<int TDIM = NDIMS>
AXOM_HOST_DEVICE std::enable_if<TDIM == 2, double>::type axom::primal::Quadrilateral< T, NDIMS >::signedVolume ( ) const
inline

Returns the signed volume of a 2D quadrilateral (synonym for signedArea())

See also
signedArea()

References axom::primal::Quadrilateral< T, NDIMS >::signedArea().

◆ print()

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

Simple formatted print of a quadrilateral instance.

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

Member Data Documentation

◆ DIM

template<typename T , int NDIMS>
constexpr int axom::primal::Quadrilateral< T, NDIMS >::DIM = NDIMS
staticconstexpr

◆ NUM_QUAD_VERTS

template<typename T , int NDIMS>
constexpr int axom::primal::Quadrilateral< T, NDIMS >::NUM_QUAD_VERTS = 4
staticconstexpr

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