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

Detailed Description

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

A direction using angles in various representations.

Template Parameters
TThe implementation type used for the representation of the angles A direction is represented using two angles:
  • The horizontal angle ranging from -180 (inclusive) to 180 (exclusive) degrees which is a rotation in the horizontal plane
  • A vertical angle ranging from -90 (inclusive) to 90 (exclusive) degrees which is the rotation in the up/down direction applied after the horizontal rotation has been applied. The angles are automatically normalized to stay within the abovenmentioned ranges.

#include <Direction.h>

Public Member Functions

 DirectionOf ()
 Create a new direction with zero angles.
 
 DirectionOf (AngleOf< T > horizontal, AngleOf< T > vertical)
 Create a new direction.
 
Vector3 ToVector3 () const
 Convert the direction into a carthesian vector.
 
bool operator== (const DirectionOf< T > direction) const
 Test whether this direction is equal to another direction.
 
DirectionOf< Toperator- () const
 Negate/reverse the direction.
 

Static Public Member Functions

static DirectionOf< TFromVector3 (Vector3 vector)
 Convert a carthesian vector into a direction.
 
static DirectionOf< TDegrees (float horizontal, float vertical)
 Create a direction using angle values in degrees.
 
static DirectionOf< TRadians (float horizontal, float vertical)
 Create a direction using angle values in radians.
 

Public Attributes

AngleOf< Thorizontal
 horizontal angle, range= (-180..180]
 
AngleOf< Tvertical
 vertical angle, range in degrees = (-90..90]
 

Static Public Attributes

static const DirectionOf forward
 A forward direction with zero for both angles.
 
static const DirectionOf back
 A backward direction with horizontal angle -180 and zero vertical angle.
 
static const DirectionOf up
 A upward direction with zero horizontal angle and vertical angle 90.
 
static const DirectionOf down
 A downward direction with zero horizontal angle and vertical angle -90.
 
static const DirectionOf left
 A left-pointing direction with horizontal angle -90 and zero vertical angle.
 
static const DirectionOf right
 A right-pointing direction with horizontal angle 90 and zero vertical angle.
 

Protected Member Functions

void Normalize ()
 Normalize this vector to the specified ranges.
 

Constructor & Destructor Documentation

◆ DirectionOf()

template<typename T >
DirectionOf::DirectionOf ( AngleOf< T horizontal,
AngleOf< T vertical 
)

Create a new direction.

Parameters
horizontalThe horizontal angle
verticalThe vertical angle.

Member Function Documentation

◆ ToVector3()

template<typename T >
Vector3 Passer::LinearAlgebra::DirectionOf< T >::ToVector3 ( ) const

Convert the direction into a carthesian vector.

Returns
The carthesian vector corresponding to this direction.

◆ FromVector3()

template<typename T >
DirectionOf< T > Passer::LinearAlgebra::DirectionOf< T >::FromVector3 ( Vector3  vector)
static

Convert a carthesian vector into a direction.

Parameters
vThe carthesian vector
Returns
The direction.
Note
Information about the length of the carthesian vector is not included in this transformation.

◆ Degrees()

template<typename T >
DirectionOf< T > Passer::LinearAlgebra::DirectionOf< T >::Degrees ( float  horizontal,
float  vertical 
)
static

Create a direction using angle values in degrees.

Parameters
horizontalThe horizontal angle in degrees
verticalThe vertical angle in degrees
Returns
The direction

◆ Radians()

template<typename T >
DirectionOf< T > Passer::LinearAlgebra::DirectionOf< T >::Radians ( float  horizontal,
float  vertical 
)
static

Create a direction using angle values in radians.

Parameters
horizontalThe horizontal angle in radians
verticalThe vertical angle in radians
Returns
The direction

◆ operator==()

template<typename T >
bool Passer::LinearAlgebra::DirectionOf< T >::operator== ( const DirectionOf< T direction) const

Test whether this direction is equal to another direction.

Parameters
directionThe direction to compare to
Returns
True when the direction angles are equal, false otherwise.

◆ operator-()

template<typename T >
DirectionOf< T > Passer::LinearAlgebra::DirectionOf< T >::operator- ( ) const

Negate/reverse the direction.

Returns
The reversed direction.

Member Data Documentation

◆ forward

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

A forward direction with zero for both angles.

◆ back

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

A backward direction with horizontal angle -180 and zero vertical angle.

◆ up

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

A upward direction with zero horizontal angle and vertical angle 90.

◆ down

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

A downward direction with zero horizontal angle and vertical angle -90.

◆ left

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

A left-pointing direction with horizontal angle -90 and zero vertical angle.

◆ right

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

A right-pointing direction with horizontal angle 90 and zero vertical angle.


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