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

A sphere class. More...

#include "murl_math_sphere.h"

Public Types

using ValueType = DataType
 The template parameter value type.
 

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.
 
DataType mRadius
 The radius of the sphere.
 
UInt32 mFlags
 Sphere flags.
 

Detailed Description

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

A sphere class.

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.

References Murl::Math::Sphere< DataType >::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.

References Murl::Math::Sphere< DataType >::SetContaining().

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

References Murl::Math::Sphere< DataType >::Set().

◆ 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

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

References Murl::Math::Sphere< DataType >::mCenter, Murl::Math::Sphere< DataType >::mFlags, Murl::Math::Sphere< DataType >::mRadius, and Murl::Math::Sphere< DataType >::Unite().

◆ Set() [3/4]

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

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

References Murl::Math::Sphere< DataType >::mCenter, Murl::Math::Sphere< DataType >::mFlags, and Murl::Math::Sphere< DataType >::mRadius.

Referenced by Murl::Math::Sphere< DataType >::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 first point.
bThe second point.

References Murl::Math::Sphere< DataType >::mCenter, Murl::Math::Sphere< DataType >::mFlags, and Murl::Math::Sphere< DataType >::mRadius.

◆ 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

◆ 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

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

References Murl::Math::Sphere< DataType >::SetBounding().

Referenced by Murl::Math::Sphere< DataType >::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.

References Murl::Math::Sphere< DataType >::SetBounding().

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

References Murl::Math::Abs(), Murl::Math::Vector< DataType >::Dot(), Murl::Math::Limits< DataType >::Epsilon(), Murl::Math::Box< DataType >::GetMaximum(), Murl::Math::Box< DataType >::GetMinimum(), Murl::Math::Sphere< DataType >::mCenter, Murl::Math::Sphere< DataType >::mFlags, and Murl::Math::Sphere< DataType >::mRadius.

◆ 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
nThe number of points

References Murl::Math::Sphere< DataType >::Set().

◆ Set() [4/4]

◆ SetCenter()

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

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

References Murl::Math::Sphere< DataType >::mFlags, and Murl::Math::Sphere< DataType >::mRadius.

◆ GetRadius()

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

◆ Unite()

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

References Murl::Math::Sphere< DataType >::mCenter, and Murl::Math::Sphere< DataType >::mRadius.

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

References Murl::Math::Sphere< DataType >::mCenter, and Murl::Math::Sphere< DataType >::mRadius.

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

References Murl::Math::Sphere< DataType >::mFlags.

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

◆ GetFlags()

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

Get the flags.

Returns
The bit-mask of flags.

References Murl::Math::Sphere< DataType >::mFlags.

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

References Murl::Math::Sphere< DataType >::mCenter, Murl::Math::Sphere< DataType >::mRadius, and Murl::Util::PrintToString().


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


Copyright © 2011-2024 Spraylight GmbH.