Core 1.0
Spheroid Class Reference

Spheroids are symmetric ellipsoids, i.e., with the same radial coefficients a = b ≠ c. More...

#include <ellipse.h>

Public Member Functions

 Spheroid ()
 Empty.
 Spheroid (const Vector &, const Vector &, const double &, const double &)
 Create a spheroid.
 Spheroid (const Vector &, const Vector &, const double &)
 Create a spheroid.
 ~Spheroid ()
 Empty.
Vector Center () const
 Gets the center.
Vector GetAxis () const
 Gets the axis.
double A () const
 Half length along the axis of revolution.
double B () const
 Radius in the plane orthogonal to the axis.
Box GetBox () const
 Compute the bouding box.
Sphere GetSphere () const
 Compute the bouding sphere.
Spheroid Rotated (const Matrix &) const
 Rotates a spheroid.
Spheroid Translated (const Vector &) const
 Translates a spheroid.
double R (const Vector &) const
 Compute the squared distance between a point and the spheroid.
int Intersect (const Ray &, double &, double &) const
 Computes the intersection between a ray and the spheroid.
double Area () const
 Compute the surface area.
double Volume () const
 Compute the volume of an ellipsoid.

Protected Member Functions

double Value (const Vector &) const
 Compute the field function value of a spheroid.

Protected Attributes

Vector c = Vector::Null
 Center of the ellipsoid.
Vector axis = Vector::Z
 Axis.
double b = 1.0
 Axis length, and radial length (revolution).

Friends

std::ostream & operator<< (std::ostream &s, const Spheroid &spheroid)
 Overloaded stream operator.

Detailed Description

Spheroids are symmetric ellipsoids, i.e., with the same radial coefficients a = b ≠ c.

Symmetric spheroids are surfaces of revolution, thus the Euclidean distance of a point or the signed distance can be computed analytically.

See also
Ellipse2

Constructor & Destructor Documentation

◆ Spheroid() [1/2]

Spheroid::Spheroid ( const Vector & c,
const Vector & axis,
const double & a,
const double & b )
explicit

Create a spheroid.

Parameters
cCenter.
axisAxis (should be normalized).
a,bAxis length and radial length, should be different (a ≠ b, so that b-a is not null).

◆ Spheroid() [2/2]

Spheroid::Spheroid ( const Vector & c,
const Vector & axis,
const double & r )
explicit

Create a spheroid.

Parameters
cCenter.
axisAxis of revolution, whose norm will define the first radius.
rRadial length.

Member Function Documentation

◆ Area()

double Spheroid::Area ( ) const

Compute the surface area.

While the surface area of a general (tri-axial) spheroid involves incomplete elliptic integrals of the first and second kind, the case of an ellipsoid of revolution (or spheroid) may be expressed in terms of elementary functions.

If radial length is greater than axial length, one has an oblate spheroid; otherwize one has a prolate spheroid.

With \( \varepsilon \) the eccentricity, the area is \( 2 \pi b^2 (1 + (a^2 / (b^2 \varepsilon)) \mathrm{artanh} \varepsilon) \) for an oblate spheroid, and \( 2 \pi b^2 (1 + (a / (b \varepsilon)) \arcsin \varepsilon) \) for a prolate spheroid. The eccentricity is null for a sphere, in which case the area is \( 4 \pi b^2 \), the limit of both formulas.

◆ Intersect()

int Spheroid::Intersect ( const Ray & ray,
double & tmin,
double & tmax ) const

Computes the intersection between a ray and the spheroid.

Underlying equation is : \( x^2 / b^2 + y^2 / b^2 + z^2 / a^2 - 1 = 0 \equiv a^2 (x^2 + y^2) + b^2 z^2 - a^2 b^2 = 0 \)

Parameters
rayThe ray.
tmin,tmaxIntersection depths.

◆ R()

double Spheroid::R ( const Vector & p) const

Compute the squared distance between a point and the spheroid.

It is possible to compute the closed form expression of the distance to a spheroid if the spheroid is symmetrical in one axis, in which case the spheroid is a surface of revolution, and the computation boils down to evaluating the distance between a point and an ellipse.

Parameters
pPoint.
See also
Ellipse2::R(const Vector2&)

◆ Rotated()

Spheroid Spheroid::Rotated ( const Matrix & r) const

Rotates a spheroid.

Parameters
rRotation matrix.

◆ Translated()

Spheroid Spheroid::Translated ( const Vector & t) const

Translates a spheroid.

Parameters
tTranslation vector.

◆ Value()

double Spheroid::Value ( const Vector & p) const
protected

Compute the field function value of a spheroid.

Parameters
pPoint.

◆ operator<<

std::ostream & operator<< ( std::ostream & s,
const Spheroid & spheroid )
friend

Overloaded stream operator.

Parameters
sStream.
spheroidSpheroid.