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

Defines an oriented Sphere in 2-D (i.e., a circle) or 3-D given by its center, \( \mathcal{X} \) and radius \( \mathcal{R} \). The Sphere object provides associated operations on a sphere, such as, signed distance and orientation. More...

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

Public Member Functions

 ~Sphere ()
 Destructor. More...
 
getRadius () const
 Returns the radius of the Sphere. More...
 
const T * getCenter () const
 Returns the center of the Sphere. More...
 
computeSignedDistance (const T *q) const
 Computes the signed distance of a point to the Sphere's boundary. More...
 
int getOrientation (const T *q, double TOL=1.e-9) const
 Computes the orientation of a point with respect to the Sphere. More...
 
bool intersectsWith (const Sphere< T, NDIMS > &sphere, double TOL=1.e-9) const
 Tests if this sphere instance intersects with another sphere. More...
 
std::ostream & print (std::ostream &os) const
 Prints the Sphere information in the given output stream. More...
 
Constructors
 Sphere (T radius=1.0)
 Constructs a Sphere centered at origin with the given radius. More...
 
 Sphere (const T *center, T radius=1.0)
 Constructs a Sphere with the given center and radius. More...
 

Detailed Description

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

Defines an oriented Sphere in 2-D (i.e., a circle) or 3-D given by its center, \( \mathcal{X} \) and radius \( \mathcal{R} \). The Sphere object provides associated operations on a sphere, such as, signed distance and orientation.

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

Constructor & Destructor Documentation

◆ Sphere() [1/2]

template<typename T , int NDIMS>
axom::primal::Sphere< T, NDIMS >::Sphere ( radius = 1.0)
explicit

Constructs a Sphere centered at origin with the given radius.

Parameters
[in]radiusthe radius of the Sphere (optional).
Note
If a radius is not supplied, the default radius is 1.0.

References AXOM_STATIC_ASSERT_MSG.

◆ Sphere() [2/2]

template<typename T , int NDIMS>
axom::primal::Sphere< T, NDIMS >::Sphere ( const T *  center,
radius = 1.0 
)
explicit

Constructs a Sphere with the given center and radius.

Parameters
[in]centeruser-supplied center.
[in]radiusthe radius of the Sphere (optional).
Note
If a radius is not supplied, the default radius is 1.0.
Precondition
center != nullptr

References AXOM_STATIC_ASSERT_MSG, and SLIC_ASSERT.

◆ ~Sphere()

template<typename T , int NDIMS>
axom::primal::Sphere< T, NDIMS >::~Sphere ( )

Destructor.

Member Function Documentation

◆ getRadius()

template<typename T, int NDIMS>
T axom::primal::Sphere< T, NDIMS >::getRadius ( ) const
inline

Returns the radius of the Sphere.

Returns
r the radius of the Sphere.

Referenced by axom::primal::Sphere< T, NDIMS >::intersectsWith().

◆ getCenter()

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

Returns the center of the Sphere.

Returns
c pointer to array that holds the center of the Sphere.
Note
c points to an array that is NDIMS long.
Postcondition
c != nullptr

References axom::primal::Sphere< T, NDIMS >::computeSignedDistance(), axom::primal::Sphere< T, NDIMS >::getOrientation(), axom::primal::Sphere< T, NDIMS >::intersectsWith(), and axom::primal::Sphere< T, NDIMS >::print().

Referenced by axom::primal::Sphere< T, NDIMS >::intersectsWith().

◆ computeSignedDistance()

template<typename T , int NDIMS>
T axom::primal::Sphere< T, NDIMS >::computeSignedDistance ( const T *  q) const
inline

Computes the signed distance of a point to the Sphere's boundary.

Parameters
[in]qpointer to buffer consisting of query point coordinates.
Returns
d the computed signed distance of the point, q, to the sphere.
Note
The signed distance of a point, q, is:
  • negative inside the sphere
  • positive outside the sphere
  • zero on the boundary
Precondition
q != nullptr
q must be a pointer to an array that is at least NDIMS long

References SLIC_ASSERT.

Referenced by axom::primal::Sphere< T, NDIMS >::getCenter(), and axom::primal::Sphere< T, NDIMS >::getOrientation().

◆ getOrientation()

template<typename T , int NDIMS>
int axom::primal::Sphere< T, NDIMS >::getOrientation ( const T *  q,
double  TOL = 1.e-9 
) const
inline

Computes the orientation of a point with respect to the Sphere.

Parameters
[in]qpointer to user-supplied point q.
[in]TOLuser-supplied tolerance. Optional. Default is 1.e-9.
Returns
orient the orientation of q with respect to the sphere.
Note
This method returns one of the following values:
  • ON_BOUNDARY : if q is on the sphere's boundary
  • ON_POSITIVE_SIDE : if q is outside the sphere
  • ON_NEGATIVE_SIDE : if q is inside the sphere
See also
OrientedSide for the list of possible return values.
Precondition
q != nullptr
q must be a pointer to an array that is at least NDIMS long

References axom::primal::Sphere< T, NDIMS >::computeSignedDistance(), axom::utilities::isNearlyEqual(), axom::primal::ON_BOUNDARY, axom::primal::ON_NEGATIVE_SIDE, axom::primal::ON_POSITIVE_SIDE, and SLIC_ASSERT.

Referenced by axom::primal::Sphere< T, NDIMS >::getCenter().

◆ intersectsWith()

template<typename T , int NDIMS>
bool axom::primal::Sphere< T, NDIMS >::intersectsWith ( const Sphere< T, NDIMS > &  sphere,
double  TOL = 1.e-9 
) const
inline

Tests if this sphere instance intersects with another sphere.

Parameters
[in]spherethe sphere object to check for intersection
[in]TOLtolerance for intersection test. Optional. If not specified the default tolerance is set to 1.e-9.
Returns
status true if the sphere intersects, false otherwise.

References axom::numerics::dot_product(), axom::primal::Sphere< T, NDIMS >::getCenter(), axom::primal::Sphere< T, NDIMS >::getRadius(), and axom::utilities::isNearlyEqual().

Referenced by axom::primal::Sphere< T, NDIMS >::getCenter(), and axom::primal::intersect().

◆ print()

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

Prints the Sphere information in the given output stream.

Parameters
[in,out]osthe output stream to write to.
Note
This method is primarily used for debugging.
Returns
s the modified output stream object.

Referenced by axom::primal::Sphere< T, NDIMS >::getCenter().


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