Thea
Public Member Functions | List of all members
BallN< N, T > Class Template Reference

A ball in N-space. More...

#include <BallN.hpp>

Inheritance diagram for BallN< N, T >:
RayIntersectableN< N, T >

Public Member Functions

 BallN ()
 Default constructor. More...
 
 BallN (VectorT const &center_, T const &radius_)
 Initialize with a center and a radius. More...
 
 BallN (BallN const &src)
 Copy constructor. More...
 
template<typename U >
BallN< N, U > cast () const
 Cast the ball to a different scalar type. More...
 
bool contains (VectorT const &p) const
 Check if the ball contains a point. More...
 
bool contains (BallN const &other) const
 Check if the ball contains another ball. More...
 
bool contains (AxisAlignedBoxN< N, T > const &aab) const
 Check if the ball contains an axis-aligned box. More...
 
distance (VectorT const &p) const
 Get the distance of the ball from a point. More...
 
distance (BallN const &other) const
 Get the distance of the ball from another ball. More...
 
distance (AxisAlignedBoxN< N, T > const &aab) const
 Get the distance of the ball from an axis-aligned box. More...
 
AxisAlignedBoxN< N, T > getBounds () const
 Get a bounding box for the ball. More...
 
VectorT const & getCenter () const
 Get the center of the ball. More...
 
getDiameter () const
 Get the diameter of the ball. More...
 
getRadius () const
 Get the radius of the ball. More...
 
bool intersects (VectorT const &p) const
 Test if this ball intersects (contains) a point. More...
 
bool intersects (BallN const &other) const
 Check if the ball intersects another ball. More...
 
bool intersects (AxisAlignedBoxN< N, T > const &aab) const
 Check if the ball intersects an axis-aligned box. More...
 
RayIntersectionN< N, T > rayIntersection (RayN< N, T > const &ray, T max_time=-1) const
 Get the intersection of a ray with the object, including the hit time and the normal at the intersection point. More...
 
rayIntersectionTime (RayN< N, T > const &ray, T max_time=-1) const
 Get the time taken for a ray to intersect the object, or a negative value if there was no intersection in the forward direction. More...
 
bool rayIntersects (RayN< N, T > const &ray, T max_time=-1) const
 Check if a ray intersects the object in the forward direction. More...
 
void setCenter (VectorT const &center_)
 Set the center of the ball. More...
 
void setRadius (T radius_)
 Set the radius of the ball. More...
 
template<typename OtherType >
squaredDistance (OtherType const &other) const
 Get the squared distance of the ball from a point, ball or axis-aligned box. More...
 
squaredDistance (AxisAlignedBoxN< N, T > const &aab, VectorT *this_pt=nullptr, VectorT *other_pt=nullptr) const
 Get the squared distance of the ball from an axis-aligned box and optionally return the closest pair of points. More...
 
std::string toString () const
 Get a textual representation of the ball. More...
 

Detailed Description

template<int N, typename T = Real>
class Thea::BallN< N, T >

A ball in N-space.

Note
A (N - 1)-sphere is the (N - 1)-dimensional surface of a N-dimensional ball.

Definition at line 33 of file BallN.hpp.

Constructor & Destructor Documentation

BallN ( )

Default constructor.

Does not initialize anything.

Definition at line 41 of file BallN.hpp.

BallN ( VectorT const &  center_,
T const &  radius_ 
)

Initialize with a center and a radius.

Definition at line 44 of file BallN.hpp.

BallN ( BallN< N, T > const &  src)

Copy constructor.

Definition at line 47 of file BallN.hpp.

Member Function Documentation

BallN<N, U> cast ( ) const

Cast the ball to a different scalar type.

Definition at line 50 of file BallN.hpp.

bool contains ( VectorT const &  p) const

Check if the ball contains a point.

Definition at line 83 of file BallN.hpp.

bool contains ( BallN< N, T > const &  other) const

Check if the ball contains another ball.

Definition at line 86 of file BallN.hpp.

bool contains ( AxisAlignedBoxN< N, T > const &  aab) const

Check if the ball contains an axis-aligned box.

Definition at line 92 of file BallN.hpp.

T distance ( VectorT const &  p) const

Get the distance of the ball from a point.

Definition at line 103 of file BallN.hpp.

T distance ( BallN< N, T > const &  other) const

Get the distance of the ball from another ball.

Definition at line 109 of file BallN.hpp.

T distance ( AxisAlignedBoxN< N, T > const &  aab) const

Get the distance of the ball from an axis-aligned box.

Definition at line 115 of file BallN.hpp.

AxisAlignedBoxN<N, T> getBounds ( ) const

Get a bounding box for the ball.

Definition at line 134 of file BallN.hpp.

VectorT const& getCenter ( ) const

Get the center of the ball.

Definition at line 53 of file BallN.hpp.

T getDiameter ( ) const

Get the diameter of the ball.

Definition at line 62 of file BallN.hpp.

T getRadius ( ) const

Get the radius of the ball.

Definition at line 59 of file BallN.hpp.

bool intersects ( VectorT const &  p) const

Test if this ball intersects (contains) a point.

Definition at line 68 of file BallN.hpp.

bool intersects ( BallN< N, T > const &  other) const

Check if the ball intersects another ball.

Definition at line 71 of file BallN.hpp.

bool intersects ( AxisAlignedBoxN< N, T > const &  aab) const

Check if the ball intersects an axis-aligned box.

Definition at line 77 of file BallN.hpp.

RayIntersectionN<N, T> rayIntersection ( RayN< N, T > const &  ray,
max_time = -1 
) const
virtual

Get the intersection of a ray with the object, including the hit time and the normal at the intersection point.

A negative time is returned if there was no intersection in the forward direction. If the normal cannot be computed, the zero vector is returned.

Parameters
rayThe ray to test for intersection.
max_timeMaximum allowable hit time, ignored if negative.
Note
The returned normal need not have unit length.

Reimplemented from RayIntersectableN< N, T >.

Definition at line 226 of file BallN.hpp.

T rayIntersectionTime ( RayN< N, T > const &  ray,
max_time = -1 
) const
virtual

Get the time taken for a ray to intersect the object, or a negative value if there was no intersection in the forward direction.

All subclasses must reimplement this method. If the return value is negative, it should be at least

Parameters
rayThe ray to test for intersection.
max_timeMaximum allowable hit time, ignored if negative.

Implements RayIntersectableN< N, T >.

Definition at line 175 of file BallN.hpp.

bool rayIntersects ( RayN< N, T > const &  ray,
max_time = -1 
) const
virtual

Check if a ray intersects the object in the forward direction.

Parameters
rayThe ray to test for intersection.
max_timeMaximum allowable hit time, ignored if negative.

Reimplemented from RayIntersectableN< N, T >.

Definition at line 148 of file BallN.hpp.

void setCenter ( VectorT const &  center_)

Set the center of the ball.

Definition at line 56 of file BallN.hpp.

void setRadius ( radius_)

Set the radius of the ball.

Definition at line 65 of file BallN.hpp.

T squaredDistance ( OtherType const &  other) const

Get the squared distance of the ball from a point, ball or axis-aligned box.

Definition at line 121 of file BallN.hpp.

T squaredDistance ( AxisAlignedBoxN< N, T > const &  aab,
VectorT *  this_pt = nullptr,
VectorT *  other_pt = nullptr 
) const

Get the squared distance of the ball from an axis-aligned box and optionally return the closest pair of points.

Definition at line 125 of file BallN.hpp.

std::string toString ( ) const

Get a textual representation of the ball.

Definition at line 141 of file BallN.hpp.


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