struct TSphere

template<typename T>

A sphere represented by a center point and a radius.

Public

Constructors

TSphere<T>

TSphere<T>()

Default constructor.

Creates a unit sphere around the origin.

TSphere<T>

TSphere<T>(const TVector3<T> &center, T radius)

TSphere

TSphere()

Default constructor.

Creates a unit sphere around the origin.

TSphere

TSphere(const TVector3<float> &center, float radius)

TSphere

TSphere()

Default constructor.

Creates a unit sphere around the origin.

TSphere

TSphere(const TVector3<double> &center, double radius)

Methods

Merge

void Merge(const TSphere<T> &rhs)

Merges the two spheres, creating a new sphere that encapsulates them both.

Merge

void Merge(const TVector3<T> &point)

Expands the sphere so it includes the provided point.

Transform

void Transform(const TMatrix4<T> &matrix)

Transforms the sphere by the given matrix.

Contains

bool Contains(const TVector3<T> &v) const

Returns whether or not this sphere contains the provided point.

Intersects

bool Intersects(const TSphere<T> &s) const

Returns whether or not this sphere intersects another sphere.

Intersects

bool Intersects(const TAABox<T> &box) const

Returns whether or not this sphere intersects a box.

Intersects

bool Intersects(const TPlane<T> &plane) const

Returns whether or not this sphere intersects a plane.

Intersects

std::pair<bool, T> Intersects(const TRay<T> &ray, bool discardInside = true) const

Ray/sphere intersection, returns boolean result and distance to nearest intersection.

ray
Ray to intersect with the sphere.
discardInside
(optional) If true the intersection will be discarded if ray origin is located within the sphere.

Merge

void Merge(const TSphere<float> &rhs)

Merges the two spheres, creating a new sphere that encapsulates them both.

Merge

void Merge(const TVector3<float> &point)

Expands the sphere so it includes the provided point.

Transform

void Transform(const TMatrix4<float> &matrix)

Transforms the sphere by the given matrix.

Contains

bool Contains(const TVector3<float> &v) const

Returns whether or not this sphere contains the provided point.

Intersects

bool Intersects(const TSphere<float> &s) const

Returns whether or not this sphere intersects another sphere.

Intersects

bool Intersects(const TAABox<float> &box) const

Returns whether or not this sphere intersects a box.

Intersects

bool Intersects(const TPlane<float> &plane) const

Returns whether or not this sphere intersects a plane.

Intersects

std::pair<bool, float> Intersects(const TRay<float> &ray, bool discardInside) const

Ray/sphere intersection, returns boolean result and distance to nearest intersection.

ray
Ray to intersect with the sphere.
discardInside
(optional) If true the intersection will be discarded if ray origin is located within the sphere.

Merge

void Merge(const TSphere<double> &rhs)

Merges the two spheres, creating a new sphere that encapsulates them both.

Merge

void Merge(const TVector3<double> &point)

Expands the sphere so it includes the provided point.

Transform

void Transform(const TMatrix4<double> &matrix)

Transforms the sphere by the given matrix.

Contains

bool Contains(const TVector3<double> &v) const

Returns whether or not this sphere contains the provided point.

Intersects

bool Intersects(const TSphere<double> &s) const

Returns whether or not this sphere intersects another sphere.

Intersects

bool Intersects(const TAABox<double> &box) const

Returns whether or not this sphere intersects a box.

Intersects

bool Intersects(const TPlane<double> &plane) const

Returns whether or not this sphere intersects a plane.

Intersects

std::pair<bool, double> Intersects(const TRay<double> &ray, bool discardInside) const

Ray/sphere intersection, returns boolean result and distance to nearest intersection.

ray
Ray to intersect with the sphere.
discardInside
(optional) If true the intersection will be discarded if ray origin is located within the sphere.

Fields

Radius

T Radius

Center

TVector3<T> Center

Radius

float Radius

Center

TVector3<float> Center

Radius

double Radius

Center

TVector3<double> Center