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

The point class represents a point, \( p \in \mathcal{R}^d \) . It provides access methods to set and query the point coordinates. More...

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

Inheritance diagram for axom::primal::Point< T, NDIMS >:

Public Types

enum  { DIMENSION = NDIMS, NBYTES = NDIMS * sizeof(T) }
 
typedef Point< T, NDIMS > PointType
 
typedef T CoordType
 

Public Member Functions

AXOM_HOST_DEVICE Point (T val=T(), int sz=NDIMS)
 Fill the first sz coordinates with val and zeros the rest. More...
 
AXOM_HOST_DEVICE Point (const NumericArray< T, NDIMS > &arr)
 Constructor from a numeric array. More...
 
AXOM_HOST_DEVICE Point (const T *vals, int sz=NDIMS)
 Creates a point from the first sz values of the input array. More...
 
 Point (std::initializer_list< T > values)
 Creates a point from an initializer list. More...
 
AXOM_HOST_DEVICE Point (const Point &other)
 Copy constructor. More...
 
AXOM_HOST_DEVICE ~Point ()
 Destructor. More...
 
AXOM_HOST_DEVICE Pointoperator= (const Point &rhs)
 Assignment operator. More...
 
AXOM_HOST_DEVICE const NumericArray< T, NDIMS > & array () const
 Returns a reference to the underlying NumericArray. More...
 
AXOM_HOST_DEVICE NumericArray< T, NDIMS > & array ()
 
void to_array (T *arr) const
 Output the point's coordinates to the array. More...
 
std::ostream & print (std::ostream &os) const
 Simple formatted print of a point instance. More...
 
Overloaded [] operator methods
AXOM_HOST_DEVICE const T & operator[] (int i) const
 Access operator for individual components. More...
 
AXOM_HOST_DEVICE T & operator[] (int i)
 
Raw data member access methods
const T * data () const
 Returns a pointer to the underlying data. More...
 
T * data ()
 

Static Public Member Functions

static int dimension ()
 Returns the dimension of this point instance. More...
 
static AXOM_HOST_DEVICE Point make_point (const T &x, const T &y, const T &z=0.0)
 Utility function to constructs a Point with the given coordinates. More...
 
static Point midpoint (const Point &A, const Point &B)
 Returns the midpoint between point A and point B. More...
 
static Point lerp (const Point &A, const Point &B, T alpha)
 Performs linear interpolation/extrapolation between two points. More...
 
static Point zero ()
 Helper function to return a point whose coordinates are all 0. More...
 
static Point ones ()
 Helper function to return a point whose coordinates are all 1 This is equivalent to using the single value constructor: Point(1) (with the appropriate casting) and is only valid for Points with a numerical type (i.e. where static_cast<T>(1) is valid. More...
 

Friends

bool operator== (const Point &lhs, const Point &rhs)
 Equality comparison operator for points. More...
 
bool operator!= (const Point &lhs, const Point &rhs)
 Inequality operator for points. More...
 

Detailed Description

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

The point class represents a point, \( p \in \mathcal{R}^d \) . It provides access methods to set and query the point coordinates.

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

Member Typedef Documentation

◆ PointType

template<typename T, int NDIMS>
typedef Point<T, NDIMS> axom::primal::Point< T, NDIMS >::PointType

◆ CoordType

template<typename T, int NDIMS>
typedef T axom::primal::Point< T, NDIMS >::CoordType

Member Enumeration Documentation

◆ anonymous enum

template<typename T, int NDIMS>
anonymous enum
Enumerator
DIMENSION 
NBYTES 

Constructor & Destructor Documentation

◆ Point() [1/5]

template<typename T, int NDIMS>
AXOM_HOST_DEVICE axom::primal::Point< T, NDIMS >::Point ( val = T(),
int  sz = NDIMS 
)
inlineexplicit

Fill the first sz coordinates with val and zeros the rest.

Parameters
[in]valThe value to set the coordinates to. Defaults to zero
[in]szThe number of coordinates to set to val. The rest will be set to zero. Defaults is NDIMS. If sz is greater than NDIMS, we set all coordinates to val

Referenced by axom::primal::Point< IndexType, NDIMS >::make_point(), axom::primal::Point< IndexType, NDIMS >::ones(), and axom::primal::Point< IndexType, NDIMS >::zero().

◆ Point() [2/5]

template<typename T, int NDIMS>
AXOM_HOST_DEVICE axom::primal::Point< T, NDIMS >::Point ( const NumericArray< T, NDIMS > &  arr)
inline

Constructor from a numeric array.

Parameters
[in]arrThe numeric array to copy from

◆ Point() [3/5]

template<typename T, int NDIMS>
AXOM_HOST_DEVICE axom::primal::Point< T, NDIMS >::Point ( const T *  vals,
int  sz = NDIMS 
)
inline

Creates a point from the first sz values of the input array.

Parameters
[in]valsAn array containing at least sz values
[in]sznum values to copy from the vals array. Defaults to NDIMS.
Note
If sz is greater than NDIMS, we only take the first NDIMS values.

◆ Point() [4/5]

template<typename T, int NDIMS>
axom::primal::Point< T, NDIMS >::Point ( std::initializer_list< T >  values)
inline

Creates a point from an initializer list.

Parameters
[in]valuesan initializer list containing the values of the point. If the size is not the same as the size of this point, this behaves the same way as the constructor which takes a pointer and size.

◆ Point() [5/5]

template<typename T, int NDIMS>
AXOM_HOST_DEVICE axom::primal::Point< T, NDIMS >::Point ( const Point< T, NDIMS > &  other)
inline

Copy constructor.

Parameters
[in]otherThe point to copy

◆ ~Point()

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

Destructor.

Member Function Documentation

◆ dimension()

template<typename T, int NDIMS>
static int axom::primal::Point< T, NDIMS >::dimension ( )
inlinestatic

Returns the dimension of this point instance.

Returns
d the dimension of the point.
Postcondition
d >= 1.

◆ operator=()

template<typename T, int NDIMS>
AXOM_HOST_DEVICE Point& axom::primal::Point< T, NDIMS >::operator= ( const Point< T, NDIMS > &  rhs)
inline

Assignment operator.

Parameters
[in]rhsa point instance on the right hand side.

◆ operator[]() [1/2]

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

Access operator for individual components.

Parameters
[in]ithe component index to access
Returns
p[i] the value at the given component index.
Precondition
(i >= 0) && (i < ndims)

◆ operator[]() [2/2]

template<typename T, int NDIMS>
AXOM_HOST_DEVICE T& axom::primal::Point< T, NDIMS >::operator[] ( int  i)
inline

◆ data() [1/2]

template<typename T, int NDIMS>
const T* axom::primal::Point< T, NDIMS >::data ( ) const
inline

Returns a pointer to the underlying data.

Referenced by axom::quest::SignedDistance< NDIMS >::computeDistance().

◆ data() [2/2]

template<typename T, int NDIMS>
T* axom::primal::Point< T, NDIMS >::data ( )
inline

◆ array() [1/2]

◆ array() [2/2]

template<typename T, int NDIMS>
AXOM_HOST_DEVICE NumericArray<T, NDIMS>& axom::primal::Point< T, NDIMS >::array ( )
inline

◆ to_array()

template<typename T, int NDIMS>
void axom::primal::Point< T, NDIMS >::to_array ( T *  arr) const
inline

Output the point's coordinates to the array.

Parameters
arrThe array that we are outputting to.
Precondition
The user needs to make sure that the array has been allocated and has sufficient space for NDIMS coordinates.

◆ print()

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

Simple formatted print of a point instance.

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

Referenced by axom::primal::operator!=(), and axom::primal::operator<<().

◆ make_point()

template<typename T, int NDIMS>
Point< T, NDIMS > axom::primal::Point< T, NDIMS >::make_point ( const T &  x,
const T &  y,
const T &  z = 0.0 
)
inlinestatic

Utility function to constructs a Point with the given coordinates.

Parameters
[in]xthe x–coordinate of the point.
[in]ythe y–coordinate of the point.
[in]zthe z–coordinate of the point. Default is 0.0.
Returns
p a Point instance with the given coordinates.

Referenced by axom::primal::BoundingBox< double, DIM >::getPoints(), and axom::primal::operator!=().

◆ midpoint()

template<typename T , int NDIMS>
Point< T, NDIMS > axom::primal::Point< T, NDIMS >::midpoint ( const Point< T, NDIMS > &  A,
const Point< T, NDIMS > &  B 
)
inlinestatic

Returns the midpoint between point A and point B.

Parameters
[in]Auser-supplied point
[in]Buser-supplied point
Returns
p point at the midpoint A and B.

Referenced by axom::primal::BoundingBox< double, DIM >::getCentroid(), and axom::primal::operator!=().

◆ lerp()

template<typename T, int NDIMS>
Point< T, NDIMS > axom::primal::Point< T, NDIMS >::lerp ( const Point< T, NDIMS > &  A,
const Point< T, NDIMS > &  B,
alpha 
)
inlinestatic

Performs linear interpolation/extrapolation between two points.

Given points A, B and a weight \( \alpha \), this method computes point \( P\) defined by \( P = (1-\alpha) \cdot A + \alpha \cdot B\)

Parameters
[in]Auser-supplied point
[in]Buser-supplied point
[in]alphauser-supplied scalar weight \( \alpha\)
Returns
P the computed point.
Note
\( \forall\alpha \in [0,1] \) this method linearly interpolates between the two points A, B.
\( \forall\alpha \not\in [0,1] \) the method extrapolates.
Postcondition
\( P==A\) when \( \alpha=0.0\)
\( P==B\) when \( \alpha=1.0\)
The return point, P, and the user-supplied points A, B are collinear.

Referenced by axom::primal::Segment< T, NDIMS >::at(), and axom::primal::operator!=().

◆ zero()

template<typename T, int NDIMS>
static Point axom::primal::Point< T, NDIMS >::zero ( )
inlinestatic

Helper function to return a point whose coordinates are all 0.

◆ ones()

template<typename T, int NDIMS>
static Point axom::primal::Point< T, NDIMS >::ones ( )
inlinestatic

Helper function to return a point whose coordinates are all 1 This is equivalent to using the single value constructor: Point(1) (with the appropriate casting) and is only valid for Points with a numerical type (i.e. where static_cast<T>(1) is valid.

Friends And Related Function Documentation

◆ operator==

template<typename T, int NDIMS>
bool operator== ( const Point< T, NDIMS > &  lhs,
const Point< T, NDIMS > &  rhs 
)
friend

Equality comparison operator for points.

◆ operator!=

template<typename T, int NDIMS>
bool operator!= ( const Point< T, NDIMS > &  lhs,
const Point< T, NDIMS > &  rhs 
)
friend

Inequality operator for points.


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