LinearAlgebra
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
Passer::LinearAlgebra::SphericalOf< T > Class Template Reference

Detailed Description

template<typename T>
class Passer::LinearAlgebra::SphericalOf< T >

A spherical vector using angles in various representations.

Template Parameters
TThe implementation type used for the representations of the agles

#include <Spherical.h>

Public Member Functions

 SphericalOf (float distance, AngleOf< T > horizontal, AngleOf< T > vertical)
 
 SphericalOf (float distance, DirectionOf< T > direction)
 
Vector3 ToVector3 () const
 Convert the spherical coordinate to a Vector3 coordinate.
 
SphericalOf< TWithDistance (float distance)
 Update the distance component of the spherical coordinate.
 
SphericalOf< Toperator- () const
 Negate the vector.
 
SphericalOf< Toperator- (const SphericalOf< T > &v) const
 Subtract a spherical vector from this vector.
 
SphericalOf< Toperator-= (const SphericalOf< T > &v)
 
SphericalOf< Toperator+ (const SphericalOf< T > &v) const
 Add a spherical vector to this vector.
 
SphericalOf< Toperator+= (const SphericalOf< T > &v)
 
SphericalOf< Toperator*= (float f)
 
SphericalOf< Toperator/= (float f)
 

Static Public Member Functions

static SphericalOf< TDegrees (float distance, float horizontal, float vertical)
 Create spherical vector without using AngleOf type. All given angles are in degrees.
 
static SphericalOf< TRadians (float distance, float horizontal, float vertical)
 Create sperical vector without using the AngleOf type. All given angles are in radians.
 
static SphericalOf< TFromPolar (PolarOf< T > v)
 Create a Spherical coordinate from a Polar coordinate.
 
static SphericalOf< TFromVector3 (Vector3 v)
 Create a Spherical coordinate from a Vector3 coordinate.
 
static float DistanceBetween (const SphericalOf< T > &v1, const SphericalOf< T > &v2)
 Calculate the distance between two spherical coordinates.
 
static AngleOf< TAngleBetween (const SphericalOf< T > &v1, const SphericalOf< T > &v2)
 Calculate the unsigned angle between two spherical vectors.
 
static AngleOf< TSignedAngleBetween (const SphericalOf< T > &v1, const SphericalOf< T > &v2, const SphericalOf< T > &axis)
 Calculate the signed angle between two spherical vectors.
 
static SphericalOf< TRotate (const SphericalOf &v, AngleOf< T > horizontalAngle, AngleOf< T > verticalAngle)
 Rotate a spherical vector.
 
static SphericalOf< TRotateHorizontal (const SphericalOf< T > &v, AngleOf< T > angle)
 Rotate a spherical vector horizontally.
 
static SphericalOf< TRotateVertical (const SphericalOf< T > &v, AngleOf< T > angle)
 Rotate a spherical vector vertically.
 

Public Attributes

float distance
 The distance in meters.
 
DirectionOf< Tdirection
 The angle in the horizontal plane in degrees, clockwise rotation.
 

Static Public Attributes

static constexpr auto Deg = Degrees
 Short-hand Deg alias for the Degrees function.
 
static constexpr auto Rad = Radians
 
static const SphericalOf< Tzero
 A spherical vector with zero degree angles and distance.
 
static const SphericalOf< Tforward
 A normalized forward-oriented vector.
 
static const SphericalOf< Tback
 A normalized back-oriented vector.
 
static const SphericalOf< Tright
 A normalized right-oriented vector.
 
static const SphericalOf< Tleft
 A normalized left-oriented vector.
 
static const SphericalOf< Tup
 A normalized up-oriented vector.
 
static const SphericalOf< Tdown
 A normalized down-oriented vector.
 

Friends

SphericalOf< Toperator* (const SphericalOf< T > &v, float f)
 Scale the vector uniformly up.
 
SphericalOf< Toperator* (float f, const SphericalOf< T > &v)
 
SphericalOf< Toperator/ (const SphericalOf< T > &v, float f)
 Scale the vector uniformly down.
 
SphericalOf< Toperator/ (float f, const SphericalOf< T > &v)
 

Member Function Documentation

◆ Degrees()

template<typename T >
SphericalOf< T > SphericalOf::Degrees ( float  distance,
float  horizontal,
float  vertical 
)
static

Create spherical vector without using AngleOf type. All given angles are in degrees.

Parameters
distanceThe distance in meters
horizontalThe horizontal angle in degrees
verticalThe vertical angle in degrees
Returns
The spherical vector

◆ Radians()

template<typename T >
SphericalOf< T > SphericalOf::Radians ( float  distance,
float  horizontal,
float  vertical 
)
static

Create sperical vector without using the AngleOf type. All given angles are in radians.

Parameters
distanceThe distance in meters
horizontalThe horizontal angle in radians
verticalThe vertical angle in radians
Returns
The spherical vectpr

◆ FromPolar()

template<typename T >
SphericalOf< T > SphericalOf::FromPolar ( PolarOf< T v)
static

Create a Spherical coordinate from a Polar coordinate.

Parameters
vThe polar coordinate
Returns
The spherical coordinate with the vertical angle set to zero.

◆ FromVector3()

template<typename T >
SphericalOf< T > SphericalOf::FromVector3 ( Vector3  v)
static

Create a Spherical coordinate from a Vector3 coordinate.

Parameters
vThe vector coordinate
Returns
The spherical coordinate

◆ ToVector3()

template<typename T >
Vector3 SphericalOf::ToVector3 ( ) const

Convert the spherical coordinate to a Vector3 coordinate.

Converts spherical coordinates to a 3D vector.

Returns
The vector coordinate

This function converts the spherical coordinates represented by the SphericalOf object to a 3D vector (Vector3). The conversion is based on the distance and direction (vertical and horizontal angles) of the spherical coordinates.

Template Parameters
TThe type of the distance and direction values.
Returns
Vector3 The 3D vector representation of the spherical coordinates.

◆ WithDistance()

template<typename T >
SphericalOf< T > SphericalOf::WithDistance ( float  distance)

Update the distance component of the spherical coordinate.

Parameters
distanceThe new distance
Returns
The updated coordinate

◆ operator-() [1/2]

template<typename T >
SphericalOf< T > SphericalOf::operator- ( ) const

Negate the vector.

Returns
The negated vector This will rotate the vector by 180 degrees horizontally and vertically. Distance will stay the same.

◆ operator-() [2/2]

Subtract a spherical vector from this vector.

Parameters
vThe vector to subtract
Returns
The result of the subtraction

◆ operator+()

template<typename T >
SphericalOf< T > SphericalOf::operator+ ( const SphericalOf< T > &  v) const

Add a spherical vector to this vector.

Parameters
vThe vector to add
Returns
The result of the addition

◆ DistanceBetween()

template<typename T >
float SphericalOf::DistanceBetween ( const SphericalOf< T > &  v1,
const SphericalOf< T > &  v2 
)
static

Calculate the distance between two spherical coordinates.

Parameters
v1The first coordinate
v2The second coordinate
Returns
The distance between the coordinates in meters

◆ AngleBetween()

template<typename T >
AngleOf< T > SphericalOf::AngleBetween ( const SphericalOf< T > &  v1,
const SphericalOf< T > &  v2 
)
static

Calculate the unsigned angle between two spherical vectors.

Parameters
v1The first vector
v2The second vector
Returns
The unsigned angle between the vectors

◆ SignedAngleBetween()

template<typename T >
AngleOf< T > Passer::LinearAlgebra::SphericalOf< T >::SignedAngleBetween ( const SphericalOf< T > &  v1,
const SphericalOf< T > &  v2,
const SphericalOf< T > &  axis 
)
static

Calculate the signed angle between two spherical vectors.

Parameters
v1The first vector
v2The second vector
axisThe axis are which the angle is calculated
Returns
The signed angle between the vectors

◆ Rotate()

template<typename T >
SphericalOf< T > SphericalOf::Rotate ( const SphericalOf< T > &  v,
AngleOf< T horizontalAngle,
AngleOf< T verticalAngle 
)
static

Rotate a spherical vector.

Parameters
vThe vector to rotate
horizontalAngleThe horizontal rotation angle in local space
verticalAngleThe vertical rotation angle in local space
Returns
The rotated vector

◆ RotateHorizontal()

template<typename T >
SphericalOf< T > SphericalOf::RotateHorizontal ( const SphericalOf< T > &  v,
AngleOf< T angle 
)
static

Rotate a spherical vector horizontally.

Parameters
vThe vector to rotate
angleThe horizontal rotation angle in local space
Returns
The rotated vector

◆ RotateVertical()

template<typename T >
SphericalOf< T > SphericalOf::RotateVertical ( const SphericalOf< T > &  v,
AngleOf< T angle 
)
static

Rotate a spherical vector vertically.

Parameters
vThe vector to rotate
angleThe vertical rotation angle in local space
Returns
The rotated vector

Friends And Related Symbol Documentation

◆ operator*

template<typename T >
SphericalOf< T > operator* ( const SphericalOf< T > &  v,
float  f 
)
friend

Scale the vector uniformly up.

Parameters
fThe scaling factor
Returns
The scaled vector
Remarks
This operation will scale the distance of the vector. The angle will be unaffected.

◆ operator/

template<typename T >
SphericalOf< T > operator/ ( const SphericalOf< T > &  v,
float  f 
)
friend

Scale the vector uniformly down.

Parameters
fThe scaling factor
Returns
The scaled factor
Remarks
This operation will scale the distance of the vector. The angle will be unaffected.

Member Data Documentation

◆ distance

The distance in meters.

Remarks
The distance should never be negative

◆ direction

The angle in the horizontal plane in degrees, clockwise rotation.

The angle is automatically normalized to -180 .. 180

The angle in the vertical plane in degrees. Positive is upward.

The angle is automatically normalized to -180 .. 180

◆ zero

template<typename T >
const SphericalOf< T > SphericalOf::zero
static
Initial value:
=
SphericalOf<T>(0.0f, AngleOf<T>(), AngleOf<T>())

A spherical vector with zero degree angles and distance.

◆ forward

template<typename T >
const SphericalOf< T > SphericalOf::forward
static
Initial value:
=
SphericalOf<T>(1.0f, AngleOf<T>(), AngleOf<T>())

A normalized forward-oriented vector.

◆ back

template<typename T >
const SphericalOf< T > SphericalOf::back
static
Initial value:
=
SphericalOf<T>(1.0f, AngleOf<T>::Degrees(180), AngleOf<T>())
static AngleOf< T > Degrees(float degrees)
Creates an angle in degrees.

A normalized back-oriented vector.

◆ right

template<typename T >
const SphericalOf< T > SphericalOf::right
static
Initial value:
=
SphericalOf<T>(1.0f, AngleOf<T>::Degrees(90), AngleOf<T>())

A normalized right-oriented vector.

◆ left

template<typename T >
const SphericalOf< T > SphericalOf::left
static
Initial value:
=
SphericalOf<T>(1.0f, AngleOf<T>::Degrees(-90), AngleOf<T>())

A normalized left-oriented vector.

◆ up

template<typename T >
const SphericalOf< T > SphericalOf::up
static
Initial value:
=
SphericalOf<T>(1.0f, AngleOf<T>(), AngleOf<T>::Degrees(90))

A normalized up-oriented vector.

◆ down

template<typename T >
const SphericalOf< T > SphericalOf::down
static
Initial value:
=
SphericalOf<T>(1.0f, AngleOf<T>(), AngleOf<T>::Degrees(-90))

A normalized down-oriented vector.


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