Ocean
Loading...
Searching...
No Matches
Ocean::SphereT3< T > Class Template Reference

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

#include <Sphere3.h>

Inheritance diagram for Ocean::SphereT3< T >:

Public Member Functions

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

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

Protected Attributes

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

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 ( ) const
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 ( ) const
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 ( ) const
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: