Murl::Math::Sphere< DataType > Class Template Reference

A sphere class. More...

#include "murl_math_sphere.h"

Public Types

typedef DataType ValueType
 The template parameter value type. More...
 

Public Member Functions

 Sphere ()
 The default constructor.
 
 Sphere (const Sphere &s1, const Sphere &s2)
 Constructor uniting two given spheres. More...
 
 Sphere (const Vector< DataType > &center, DataType radius)
 Constructor taking a center position vector and a radius. More...
 
 Sphere (DataType centerX, DataType centerY, DataType centerZ, DataType radius)
 Constructor taking individual center position coordinates and a radius. More...
 
 Sphere (const Vector< DataType > &a, const Vector< DataType > &b, const Vector< DataType > &c)
 Constructor taking the three points of a triangle. More...
 
 Sphere (const Box< DataType > &box)
 Constructor taking a box. More...
 
template<class DataType2 >
 Sphere (const Sphere< DataType2 > &s)
 The copy constructor using a sphere of different type. More...
 
void Clear ()
 Clear the sphere.
 
void Set (const Sphere &other)
 Copy the content of a source sphere to the sphere instance. More...
 
void Set (const Sphere &s1, const Sphere &s2)
 Unite two spheres to the sphere instance. More...
 
void Set (const Vector< DataType > &center, DataType radius)
 Set a center position vector and a radius. More...
 
void SetBounding (const Vector< DataType > &a)
 Set the sphere containing a single point. More...
 
void SetBounding (const Vector< DataType > &a, const Vector< DataType > &b)
 Set the sphere containing two points. More...
 
void SetBounding (const Vector< DataType > &a, const Vector< DataType > &b, const Vector< DataType > &c)
 Set the sphere using three points lying on the sphere boundary. More...
 
void SetBounding (const Vector< DataType > &a, const Vector< DataType > &b, const Vector< DataType > &c, const Vector< DataType > &d)
 Set the sphere using four points lying on the sphere boundary. More...
 
void SetContaining (const Vector< DataType > &a)
 Set the sphere containing a single point. More...
 
void SetContaining (const Vector< DataType > &a, const Vector< DataType > &b)
 Set the sphere containing two points. More...
 
void SetContaining (const Vector< DataType > &a, const Vector< DataType > &b, const Vector< DataType > &c)
 Set the sphere containing three points. More...
 
void SetContaining (const Vector< DataType > *p, UInt32 n)
 Set the sphere containing a number of given points. More...
 
void Set (const Box< DataType > &box)
 Set the sphere to fit into a box. More...
 
void SetCenter (const Vector< DataType > &center)
 Set the center position. More...
 
const Vector< DataType > & GetCenter () const
 Get the center position. More...
 
void SetRadius (DataType radius)
 Set the radius. More...
 
DataType GetRadius () const
 Get the radius. More...
 
void Unite (const Sphere &other)
 Unite this sphere with another sphere. More...
 
void Include (const Vector< DataType > &point)
 Include a point in this sphere. More...
 
Bool IsIntersecting (const Sphere &other) const
 Check if a given sphere is intersecting this sphere. More...
 
Bool IsContaining (const Vector< DataType > &p) const
 Check if a given point is inside this sphere. More...
 
Bool IsEmpty () const
 Check if a the sphere is empty. More...
 
UInt32 GetFlags () const
 Get the flags. More...
 
String ToString () const
 Get the string representation of the object. More...
 

Protected Attributes

Vector< DataType > mCenter
 The center position of the sphere. More...
 
DataType mRadius
 The radius of the sphere. More...
 
UInt32 mFlags
 Sphere flags. More...
 

Detailed Description

template<class DataType>
class Murl::Math::Sphere< DataType >

A sphere class.

Member Typedef Documentation

◆ ValueType

template<class DataType>
typedef DataType Murl::Math::Sphere< DataType >::ValueType

The template parameter value type.

Constructor & Destructor Documentation

◆ Sphere() [1/6]

template<class DataType>
Murl::Math::Sphere< DataType >::Sphere ( const Sphere< DataType > &  s1,
const Sphere< DataType > &  s2 
)
inline

Constructor uniting two given spheres.

Parameters
s1The first sphere to unite.
s2The second sphere to unite.

◆ Sphere() [2/6]

template<class DataType>
Murl::Math::Sphere< DataType >::Sphere ( const Vector< DataType > &  center,
DataType  radius 
)
inline

Constructor taking a center position vector and a radius.

Parameters
centerThe center position.
radiusThe radius.

◆ Sphere() [3/6]

template<class DataType>
Murl::Math::Sphere< DataType >::Sphere ( DataType  centerX,
DataType  centerY,
DataType  centerZ,
DataType  radius 
)
inline

Constructor taking individual center position coordinates and a radius.

Parameters
centerXThe center x-position coordinate.
centerYThe center y-position coordinate.
centerZThe center z-position coordinate.
radiusThe radius.

◆ Sphere() [4/6]

template<class DataType>
Murl::Math::Sphere< DataType >::Sphere ( const Vector< DataType > &  a,
const Vector< DataType > &  b,
const Vector< DataType > &  c 
)
inline

Constructor taking the three points of a triangle.

Parameters
aThe first triangle point.
bThe second triangle point.
cThe third triangle point.

◆ Sphere() [5/6]

template<class DataType>
Murl::Math::Sphere< DataType >::Sphere ( const Box< DataType > &  box)
inline

Constructor taking a box.

Parameters
boxThe box to fit in.

◆ Sphere() [6/6]

template<class DataType>
template<class DataType2 >
Murl::Math::Sphere< DataType >::Sphere ( const Sphere< DataType2 > &  s)
inline

The copy constructor using a sphere of different type.

Parameters
sThe sphere to copy.

Member Function Documentation

◆ Set() [1/4]

template<class DataType>
void Murl::Math::Sphere< DataType >::Set ( const Sphere< DataType > &  other)
inline

Copy the content of a source sphere to the sphere instance.

Parameters
otherThe sphere to copy from.

Referenced by Murl::Math::Sphere< Real >::SetContaining(), Murl::Math::Sphere< Real >::Sphere(), and Murl::Math::Sphere< Real >::Unite().

◆ Set() [2/4]

template<class DataType>
void Murl::Math::Sphere< DataType >::Set ( const Sphere< DataType > &  s1,
const Sphere< DataType > &  s2 
)
inline

Unite two spheres to the sphere instance.

Parameters
s1The first sphere to unite.
s2The second sphere to unite.

◆ Set() [3/4]

template<class DataType>
void Murl::Math::Sphere< DataType >::Set ( const Vector< DataType > &  center,
DataType  radius 
)
inline

Set a center position vector and a radius.

Parameters
centerThe center position.
radiusThe radius.

◆ SetBounding() [1/4]

template<class DataType>
void Murl::Math::Sphere< DataType >::SetBounding ( const Vector< DataType > &  a)
inline

Set the sphere containing a single point.

The center of the sphere is set to the given point, and the radius to 0.

Parameters
aThe point.

Referenced by Murl::Math::Sphere< Real >::SetContaining().

◆ SetBounding() [2/4]

template<class DataType>
void Murl::Math::Sphere< DataType >::SetBounding ( const Vector< DataType > &  a,
const Vector< DataType > &  b 
)
inline

Set the sphere containing two points.

The center of the sphere is set to the position at half way between the given points, and the radius to half their distance.

Parameters
aThe point.

◆ SetBounding() [3/4]

template<class DataType>
void Murl::Math::Sphere< DataType >::SetBounding ( const Vector< DataType > &  a,
const Vector< DataType > &  b,
const Vector< DataType > &  c 
)
inline

Set the sphere using three points lying on the sphere boundary.

Parameters
aThe first point.
bThe second point.
cThe third point.

◆ SetBounding() [4/4]

template<class DataType>
void Murl::Math::Sphere< DataType >::SetBounding ( const Vector< DataType > &  a,
const Vector< DataType > &  b,
const Vector< DataType > &  c,
const Vector< DataType > &  d 
)
inline

Set the sphere using four points lying on the sphere boundary.

Parameters
aThe first point.
bThe second point.
cThe third point.
dThe fourth point.

◆ SetContaining() [1/4]

template<class DataType>
void Murl::Math::Sphere< DataType >::SetContaining ( const Vector< DataType > &  a)
inline

Set the sphere containing a single point.

Parameters
aThe point.

Referenced by Murl::Math::Sphere< Real >::Sphere().

◆ SetContaining() [2/4]

template<class DataType>
void Murl::Math::Sphere< DataType >::SetContaining ( const Vector< DataType > &  a,
const Vector< DataType > &  b 
)
inline

Set the sphere containing two points.

This is equal to setting the sphere with the given two points lying on the surface of the returned sphere.

Parameters
aThe first point.
bThe second point.

◆ SetContaining() [3/4]

template<class DataType>
void Murl::Math::Sphere< DataType >::SetContaining ( const Vector< DataType > &  a,
const Vector< DataType > &  b,
const Vector< DataType > &  c 
)
inline

Set the sphere containing three points.

This is different to SetBounding() in that one of the given points may lie inside the returned sphere and not on the boundary.

Parameters
aThe first point.
bThe second point.
cThe third point.

◆ SetContaining() [4/4]

template<class DataType>
void Murl::Math::Sphere< DataType >::SetContaining ( const Vector< DataType > *  p,
UInt32  n 
)
inline

Set the sphere containing a number of given points.

Parameters
pThe array of points

◆ Set() [4/4]

template<class DataType>
void Murl::Math::Sphere< DataType >::Set ( const Box< DataType > &  box)
inline

Set the sphere to fit into a box.

Parameters
boxThe box to fit in.

◆ SetCenter()

template<class DataType>
void Murl::Math::Sphere< DataType >::SetCenter ( const Vector< DataType > &  center)
inline

Set the center position.

Parameters
centerThe center position.

◆ GetCenter()

template<class DataType>
const Vector<DataType>& Murl::Math::Sphere< DataType >::GetCenter ( ) const
inline

◆ SetRadius()

template<class DataType>
void Murl::Math::Sphere< DataType >::SetRadius ( DataType  radius)
inline

Set the radius.

Parameters
radiusThe radius.

◆ GetRadius()

template<class DataType>
DataType Murl::Math::Sphere< DataType >::GetRadius ( ) const
inline

◆ Unite()

template<class DataType>
void Murl::Math::Sphere< DataType >::Unite ( const Sphere< DataType > &  other)
inline

Unite this sphere with another sphere.

Parameters
otherThe other sphere to unite.

Referenced by Murl::Math::Sphere< Real >::Set(), and Murl::Math::Sphere< Real >::Sphere().

◆ Include()

template<class DataType>
void Murl::Math::Sphere< DataType >::Include ( const Vector< DataType > &  point)
inline

Include a point in this sphere.

Parameters
pointThe point to include.

◆ IsIntersecting()

template<class DataType>
Bool Murl::Math::Sphere< DataType >::IsIntersecting ( const Sphere< DataType > &  other) const
inline

Check if a given sphere is intersecting this sphere.

Parameters
otherThe other sphere to check.
Returns
true if the other sphere is intersecting this sphere.

◆ IsContaining()

template<class DataType>
Bool Murl::Math::Sphere< DataType >::IsContaining ( const Vector< DataType > &  p) const
inline

Check if a given point is inside this sphere.

Parameters
pThe point to check.
Returns
true if the point is inside this sphere.

◆ IsEmpty()

template<class DataType>
Bool Murl::Math::Sphere< DataType >::IsEmpty ( ) const
inline

Check if a the sphere is empty.

A sphere is only empty when created with the default constructor, explicitly cleared by calling Clear(), or duplicated from another empty sphere or box. As soon as a single point is included, the sphere is considered "not empty".

Returns
true if the box is empty.

Referenced by Murl::Math::Sphere< Real >::Clear(), Murl::Math::Sphere< Real >::IsContaining(), Murl::Math::Sphere< Real >::IsIntersecting(), Murl::Math::Box< Real >::Set(), and Murl::Math::Sphere< Real >::Unite().

◆ GetFlags()

template<class DataType>
UInt32 Murl::Math::Sphere< DataType >::GetFlags ( ) const
inline

Get the flags.

Returns
The bit-mask of flags.

◆ ToString()

template<class DataType>
String Murl::Math::Sphere< DataType >::ToString ( ) const
inline

Get the string representation of the object.

Returns
The string representation of the object.

Member Data Documentation

◆ mCenter

◆ mRadius

◆ mFlags


The documentation for this class was generated from the following files:
  • murl_audio_types.h
  • murl_math_sphere.h


Copyright © 2011-2018 Spraylight GmbH.