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 > ¢er, 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 > ¢er, 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 > ¢er) |
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]
|
inline |
Constructor uniting two given spheres.
- Parameters
-
s1 The first sphere to unite. s2 The second sphere to unite.
References Murl::Math::Sphere< DataType >::Unite().
◆ Sphere() [2/6]
|
inline |
Constructor taking a center position vector and a radius.
- Parameters
-
center The center position. radius The radius.
◆ Sphere() [3/6]
|
inline |
Constructor taking individual center position coordinates and a radius.
- Parameters
-
centerX The center x-position coordinate. centerY The center y-position coordinate. centerZ The center z-position coordinate. radius The radius.
◆ Sphere() [4/6]
|
inline |
Constructor taking the three points of a triangle.
- Parameters
-
a The first triangle point. b The second triangle point. c The third triangle point.
References Murl::Math::Sphere< DataType >::SetContaining().
◆ Sphere() [5/6]
|
inline |
Constructor taking a box.
- Parameters
-
box The box to fit in.
References Murl::Math::Sphere< DataType >::Set().
◆ Sphere() [6/6]
|
inline |
The copy constructor using a sphere of different type.
- Parameters
-
s The sphere to copy.
Member Function Documentation
◆ Set() [1/4]
|
inline |
Copy the content of a source sphere to the sphere instance.
- Parameters
-
other The sphere to copy from.
References Murl::Math::Sphere< DataType >::mCenter, Murl::Math::Sphere< DataType >::mFlags, and Murl::Math::Sphere< DataType >::mRadius.
Referenced by Murl::Math::Sphere< DataType >::SetContaining(), Murl::Math::Sphere< DataType >::Sphere(), and Murl::Math::Sphere< DataType >::Unite().
◆ Set() [2/4]
|
inline |
Unite two spheres to the sphere instance.
- Parameters
-
s1 The first sphere to unite. s2 The 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]
|
inline |
Set a center position vector and a radius.
- Parameters
-
center The center position. radius The radius.
References Murl::Math::Sphere< DataType >::mCenter, Murl::Math::Sphere< DataType >::mFlags, Murl::Math::Sphere< DataType >::mRadius, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
◆ SetBounding() [1/4]
|
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
-
a The 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]
|
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
-
a The first point. b The second point.
References Murl::Math::Sphere< DataType >::mCenter, Murl::Math::Sphere< DataType >::mFlags, and Murl::Math::Sphere< DataType >::mRadius.
◆ SetBounding() [3/4]
|
inline |
Set the sphere using three points lying on the sphere boundary.
- Parameters
-
a The first point. b The second point. c The third point.
References Murl::Math::Abs(), Murl::Math::Vector< DataType >::Cross(), Murl::Math::Box< DataType >::GetMaximum(), Murl::Math::Box< DataType >::GetMinimum(), Murl::Math::Vector< DataType >::GetSquaredLength(), Murl::Math::Sphere< DataType >::mCenter, Murl::Math::Sphere< DataType >::mFlags, and Murl::Math::Sphere< DataType >::mRadius.
◆ SetBounding() [4/4]
|
inline |
Set the sphere using four points lying on the sphere boundary.
- Parameters
-
a The first point. b The second point. c The third point. d The fourth point.
References Murl::Math::Abs(), Murl::Math::Vector< DataType >::Cross(), Murl::Math::Box< DataType >::GetMaximum(), Murl::Math::Box< DataType >::GetMinimum(), Murl::Math::Vector< DataType >::GetSquaredLength(), Murl::Math::Box< DataType >::Include(), Murl::Math::Sphere< DataType >::mCenter, Murl::Math::Sphere< DataType >::mFlags, Murl::Math::Sphere< DataType >::mRadius, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
◆ SetContaining() [1/4]
|
inline |
Set the sphere containing a single point.
- Parameters
-
a The point.
References Murl::Math::Sphere< DataType >::SetBounding().
Referenced by Murl::Math::Sphere< DataType >::Sphere().
◆ SetContaining() [2/4]
|
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
-
a The first point. b The second point.
References Murl::Math::Sphere< DataType >::SetBounding().
◆ SetContaining() [3/4]
|
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
-
a The first point. b The second point. c The 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]
|
inline |
Set the sphere containing a number of given points.
- Parameters
-
p The array of points n The number of points
References Murl::Math::Sphere< DataType >::Set().
◆ Set() [4/4]
|
inline |
Set the sphere to fit into a box.
- Parameters
-
box The box to fit in.
References Murl::Math::Sphere< DataType >::Clear(), Murl::Math::Box< DataType >::GetMaximum(), Murl::Math::Box< DataType >::GetMinimum(), Murl::Math::Box< DataType >::IsEmpty(), Murl::Math::Sphere< DataType >::mCenter, Murl::Math::Sphere< DataType >::mFlags, and Murl::Math::Sphere< DataType >::mRadius.
◆ SetCenter()
|
inline |
Set the center position.
- Parameters
-
center The center position.
References Murl::Math::Sphere< DataType >::mCenter, Murl::Math::Sphere< DataType >::mFlags, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
◆ GetCenter()
|
inline |
Get the center position.
- Returns
- The center position.
References Murl::Math::Sphere< DataType >::mCenter.
Referenced by Murl::Math::Cone< DataType >::IsIntersecting(), Murl::Math::Cylinder< DataType >::IsIntersecting(), and Murl::Math::Box< DataType >::Set().
◆ SetRadius()
|
inline |
Set the radius.
- Parameters
-
radius The radius.
References Murl::Math::Sphere< DataType >::mFlags, and Murl::Math::Sphere< DataType >::mRadius.
◆ GetRadius()
|
inline |
Get the radius.
- Returns
- The radius.
References Murl::Math::Sphere< DataType >::mRadius.
Referenced by Murl::Math::Cone< DataType >::IsIntersecting(), Murl::Math::Cylinder< DataType >::IsIntersecting(), and Murl::Math::Box< DataType >::Set().
◆ Unite()
|
inline |
Unite this sphere with another sphere.
- Parameters
-
other The other sphere to unite.
References Murl::Math::Vector< DataType >::GetLength(), Murl::Math::Box< DataType >::GetMaximum(), Murl::Math::Box< DataType >::GetMinimum(), Murl::Math::Sphere< DataType >::IsEmpty(), Murl::Math::Max(), Murl::Math::Sphere< DataType >::mCenter, Murl::Math::Sphere< DataType >::mFlags, Murl::Math::Min(), Murl::Math::Sphere< DataType >::mRadius, and Murl::Math::Sphere< DataType >::Set().
Referenced by Murl::Math::Sphere< DataType >::Set(), and Murl::Math::Sphere< DataType >::Sphere().
◆ Include()
|
inline |
Include a point in this sphere.
- Parameters
-
point The point to include.
References Murl::Math::Box< DataType >::GetMaximum(), Murl::Math::Box< DataType >::GetMinimum(), Murl::Math::Vector< DataType >::GetSquaredLength(), Murl::Math::Max(), Murl::Math::Sphere< DataType >::mCenter, Murl::Math::Sphere< DataType >::mFlags, Murl::Math::Sphere< DataType >::mRadius, and Murl::Math::Sqrt().
◆ IsIntersecting()
|
inline |
Check if a given sphere is intersecting this sphere.
- Parameters
-
other The 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()
|
inline |
Check if a given point is inside this sphere.
- Parameters
-
p The 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()
|
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()
|
inline |
◆ ToString()
|
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