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/latest/src/axom/primal/geometry/Sphere.hpp>

Public Types

using PointType = primal::Point< T, NDIMS >
 

Public Member Functions

getRadius () const
 Returns the radius of the Sphere. More...
 
const PointTypegetCenter () const
 Returns the center of the Sphere. More...
 
AXOM_HOST_DEVICEcomputeSignedDistance (const PointType &q) const
 Computes the signed distance of a point to the Sphere's boundary. More...
 
int getOrientation (const PointType &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 PointType &center, T radius=1.0)
 Constructs a Sphere with the given center and 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

Member Typedef Documentation

◆ PointType

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

Constructor & Destructor Documentation

◆ Sphere() [1/3]

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

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.

◆ Sphere() [2/3]

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

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.

◆ Sphere() [3/3]

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 SLIC_ASSERT.

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.

◆ getCenter()

template<typename T , int NDIMS>
const PointType& 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

◆ computeSignedDistance()

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

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

Parameters
[in]qThe test point
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

References axom::primal::Vector< T, NDIMS >::norm().

◆ getOrientation()

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

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

Parameters
[in]qThe test point
[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
OrientationResult for the list of possible return values.

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

◆ 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::primal::Sphere< T, NDIMS >::getCenter(), axom::primal::Sphere< T, NDIMS >::getRadius(), axom::utilities::isNearlyEqual(), and axom::primal::Vector< T, NDIMS >::squared_norm().

◆ 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.

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