Ocean
Ocean::SphereT3< T > Class Template Reference

This class implements a 3D sphere. More...

Inheritance diagram for Ocean::SphereT3< T >:

Public Member Functions

 SphereT3 ()=default
 Creates an invalid sphere. More...
 
 SphereT3 (const VectorT3< T > &center, const T radius)
 Creates a new sphere by a center point and a radius. More...
 
 SphereT3 (const BoxT3< T > &boundingBox)
 Creates a new sphere entirely containing a given 3D box. More...
 
const VectorT3< T > & center () const
 Returns the center of the sphere. More...
 
const T & radius () const
 Returns the radius of the sphere. More...
 
bool isInside (const VectorT3< T > &point) const
 Returns whether a given point is inside this sphere. More...
 
bool isInsideEps (const VectorT3< T > &point, const T eps=NumericT< T >::eps()) const
 Returns whether a given point is inside this sphere including a thin epsilon boundary. More...
 
bool hasIntersection (const LineT3< T > &ray) const
 Returns whether a given ray has an intersection with this sphere. More...
 
bool hasIntersection (const LineT3< T > &ray, const HomogenousMatrixT4< T > &sphere_T_ray) const
 Returns whether a given ray has an intersection with this sphere. More...
 
bool hasIntersection (const SphereT3< T > &sphere) const
 Returns whether two spheres have an intersection. More...
 
bool isValid () const
 Returns whether this radius of this sphere is not negative and thus the sphere is valid. More...
 
SphereT3< T > operator* (const T factor) const
 Returns a new sphere with an enlarged radius (the center of the sphere stays constant). More...
 
SphereT3< T > & operator*= (const T factor)
 Multiplies the radius of this sphere with a given factor. More...
 

Static Public Member Functions

static VectorT3< T > coordinateToVector (const T latitude, const T longitude)
 Converts a 2D location coordinate on the surface of a unit sphere to a vector with unit length. More...
 
static void vectorToCoordinate (const VectorT3< T > &coordinateVector, T &latitude, T &longitude)
 Converts a vector pointing to the surface of a unit sphere to a 2D location coordinate. More...
 
static T shortestDistance (const T latitudeA, const T longitudeA, const T latitudeB, const T longitudeB)
 Calculates the shortest distance between two 2D location coordinates on the surface of a unit sphere. More...
 

Protected Attributes

VectorT3< T > center_ = VectorT3<T>(0, 0, 0)
 Sphere center. More...
 
radius_ = T(-1)
 Sphere radius. More...
 

Detailed Description

template<typename T>
class Ocean::SphereT3< T >

This class implements a 3D sphere.

Constructor & Destructor Documentation

◆ SphereT3() [1/3]

template<typename T >
Ocean::SphereT3< T >::SphereT3 ( )
default

Creates an invalid sphere.

◆ SphereT3() [2/3]

template<typename T >
Ocean::SphereT3< T >::SphereT3 ( const VectorT3< T > &  center,
const T  radius 
)
inline

Creates a new sphere by a center point and a radius.

Parameters
centerThe center of the sphere
radiusThe radius of the sphere, with range [0, infinity), negative to create an invalid sphere

◆ SphereT3() [3/3]

template<typename T >
Ocean::SphereT3< T >::SphereT3 ( const BoxT3< T > &  boundingBox)
inlineexplicit

Creates a new sphere entirely containing a given 3D box.

Parameters
boundingBoxThe box which will be contained by the new sphere, must be valid

Member Function Documentation

◆ center()

template<typename T >
const VectorT3< T > & Ocean::SphereT3< T >::center
inline

Returns the center of the sphere.

Returns
Sphere center

◆ coordinateToVector()

template<typename T >
VectorT3< T > Ocean::SphereT3< T >::coordinateToVector ( const T  latitude,
const T  longitude 
)
static

Converts a 2D location coordinate on the surface of a unit sphere to a vector with unit length.

The north/south axis of the sphere is parallel to the y-axis, the z-axis points towards the longitude 0 at the equator, the x-axis points towards the longitude PI/2 at the equator.

Parameters
latitudeThe latitude coordinate of the location, in radian, with range [-PI/2, PI/2]
longitudeThe longitude coordinate of the location, in radian, with range [-PI, PI]
Returns
The corresponding 3D vector with unit length

◆ hasIntersection() [1/3]

template<typename T >
bool Ocean::SphereT3< T >::hasIntersection ( const LineT3< T > &  ray) const

Returns whether a given ray has an intersection with this sphere.

Parameters
rayThe ray to be tested
Returns
True, if so

◆ hasIntersection() [2/3]

template<typename T >
bool Ocean::SphereT3< T >::hasIntersection ( const LineT3< T > &  ray,
const HomogenousMatrixT4< T > &  sphere_T_ray 
) const
inline

Returns whether a given ray has an intersection with this sphere.

Parameters
rayRay to be tested, must be valid
sphere_T_rayThe transformation between ray and this sphere, must be valid
Returns
True, if so

◆ hasIntersection() [3/3]

template<typename T >
bool Ocean::SphereT3< T >::hasIntersection ( const SphereT3< T > &  sphere) const
inline

Returns whether two spheres have an intersection.

Parameters
sphereSecond sphere to test
Returns
True, if so

◆ isInside()

template<typename T >
bool Ocean::SphereT3< T >::isInside ( const VectorT3< T > &  point) const
inline

Returns whether a given point is inside this sphere.

Parameters
pointThe point to check
Returns
True, if so

◆ isInsideEps()

template<typename T >
bool Ocean::SphereT3< T >::isInsideEps ( const VectorT3< T > &  point,
const T  eps = NumericT<T>::eps() 
) const
inline

Returns whether a given point is inside this sphere including a thin epsilon boundary.

Parameters
pointThe point to check
epsEpsilon to be used, with range [0, infinity)
Returns
True, if so

◆ isValid()

template<typename T >
bool Ocean::SphereT3< T >::isValid
inline

Returns whether this radius of this sphere is not negative and thus the sphere is valid.

Returns
True, if so

◆ operator*()

template<typename T >
SphereT3< T > Ocean::SphereT3< T >::operator* ( const T  factor) const
inline

Returns a new sphere with an enlarged radius (the center of the sphere stays constant).

Parameters
factorThe factor to be multiplied with the radius of this sphere, with range [0, infinity)
Returns
New resulting sphere

◆ operator*=()

template<typename T >
SphereT3< T > & Ocean::SphereT3< T >::operator*= ( const T  factor)
inline

Multiplies the radius of this sphere with a given factor.

Parameters
factorThe factor to be multiplied with the radius, with range [0, infinity)
Returns
Reference to this sphere object

◆ radius()

template<typename T >
const T & Ocean::SphereT3< T >::radius
inline

Returns the radius of the sphere.

Returns
Sphere radius, with range [0, infinity), negative if invalid

◆ shortestDistance()

template<typename T >
T Ocean::SphereT3< T >::shortestDistance ( const T  latitudeA,
const T  longitudeA,
const T  latitudeB,
const T  longitudeB 
)
static

Calculates the shortest distance between two 2D location coordinates on the surface of a unit sphere.

The shortest distance is identical to the shortest angle (in radian) in a unit sphere.
This function applies the Haversine formula.

Parameters
latitudeAThe latitude coordinate of the first location, in radian, with range [-PI/2, PI/2]
longitudeAThe longitude coordinate of the first location, in radian, with range [-PI, PI]
latitudeBThe latitude coordinate of the second location, in radian, with range [-PI/2, PI/2]
longitudeBThe longitude coordinate of the second location, in radian, with range [-PI, PI]
Returns
The shortest distance on the unit sphere, with range [0, PI]

◆ vectorToCoordinate()

template<typename T >
void Ocean::SphereT3< T >::vectorToCoordinate ( const VectorT3< T > &  coordinateVector,
T &  latitude,
T &  longitude 
)
static

Converts a vector pointing to the surface of a unit sphere to a 2D location coordinate.

Parameters
coordinateVectorThe vector pointing to the location on the unit sphere, must have unit length
latitudeThe resulting latitude coordinate of the location, in radian, with range range [-PI/2, PI/2]
longitudeThe resulting longitude coordinate of the location, in radian, with range range [-PI, PI]

Field Documentation

◆ center_

template<typename T >
VectorT3<T> Ocean::SphereT3< T >::center_ = VectorT3<T>(0, 0, 0)
protected

Sphere center.

◆ radius_

template<typename T >
T Ocean::SphereT3< T >::radius_ = T(-1)
protected

Sphere radius.


The documentation for this class was generated from the following file: