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

Detailed Description

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

A polar vector using an angle in various representations.

Template Parameters
TThe implementation type used for the representation of the angle

#include <Polar.h>

Public Member Functions

 PolarOf ()
 A new vector with polar coordinates with zero degrees and distance.
 
 PolarOf (float distance, AngleOf< T > angle)
 A new vector with polar coordinates.
 
bool operator== (const PolarOf &v) const
 Equality test to another vector.
 
float magnitude () const
 The vector length.
 
PolarOf normalized () const
 Convert the vector to a length of a.
 
PolarOf operator- () const
 Negate the vector.
 
PolarOf operator- (const PolarOf &v) const
 Subtract a polar vector from this vector.
 
PolarOf operator-= (const PolarOf &v)
 
PolarOf operator+ (const PolarOf &v) const
 Add a polar vector to this vector.
 
PolarOf operator+= (const PolarOf &v)
 
PolarOf operator*= (float f)
 
PolarOf operator/= (float f)
 

Static Public Member Functions

static PolarOf< TDegrees (float distance, float degrees)
 Create polar vector without using AngleOf type. All given angles are in degrees.
 
static PolarOf< TRadians (float distance, float radians)
 Create polar vector without using AngleOf type. All given angles are in radians.
 
static PolarOf< TFromVector2 (Vector2 v)
 Convert a vector from 2D carthesian coordinates to polar coordinates.
 
static PolarOf< TFromSpherical (SphericalOf< T > v)
 Convert a vector from spherical coordinates to polar coordinates.
 
static float Magnitude (const PolarOf &v)
 The vector length.
 
static PolarOf Normalize (const PolarOf &v)
 Convert the vector to a length of 1.
 
static float Distance (const PolarOf &v1, const PolarOf &v2)
 The distance between two vectors.
 
static PolarOf Rotate (const PolarOf &v, AngleOf< T > a)
 Rotate a vector.
 

Public Attributes

float distance
 The distance in meters.
 
AngleOf< Tangle
 The angle 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
 Short-hand Rad alias for the Radians function.
 
static const PolarOf zero = PolarOf(0.0f, AngleOf<T>())
 A polar vector with zero degrees and distance.
 
static const PolarOf forward = PolarOf(1.0f, AngleOf<T>())
 A normalized forward-oriented vector.
 
static const PolarOf back = PolarOf(1.0, AngleOf<T>::Degrees(180))
 A normalized back-oriented vector.
 
static const PolarOf right = PolarOf(1.0, AngleOf<T>::Degrees(90))
 A normalized right-oriented vector.
 
static const PolarOf left = PolarOf(1.0, AngleOf<T>::Degrees(-90))
 A normalized left-oriented vector.
 

Friends

PolarOf operator* (const PolarOf &v, float f)
 Scale the vector uniformly up.
 
PolarOf operator* (float f, const PolarOf &v)
 
PolarOf operator/ (const PolarOf &v, float f)
 Scale the vector uniformly down.
 
PolarOf operator/ (float f, const PolarOf &v)
 

Constructor & Destructor Documentation

◆ PolarOf()

template<typename T >
PolarOf::PolarOf ( float  distance,
AngleOf< T angle 
)

A new vector with polar coordinates.

Parameters
distanceThe distance in meters
angleThe angle in degrees, clockwise rotation
Note
The distance is automatically converted to a positive value.
The angle is automatically normalized to -180 .. 180

Member Function Documentation

◆ Degrees()

template<typename T >
PolarOf< T > PolarOf::Degrees ( float  distance,
float  degrees 
)
static

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

Parameters
distanceThe distance in meters
degreesThe angle in degrees
Returns
The polar vector

◆ Radians()

template<typename T >
PolarOf< T > PolarOf::Radians ( float  distance,
float  radians 
)
static

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

Parameters
distanceThe distance in meters
radiansThe angle in radians
Returns
The polar vector

◆ FromVector2()

template<typename T >
PolarOf< T > PolarOf::FromVector2 ( Vector2  v)
static

Convert a vector from 2D carthesian coordinates to polar coordinates.

Parameters
vThe vector to convert

◆ FromSpherical()

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

Convert a vector from spherical coordinates to polar coordinates.

Parameters
sThe vector to convert
Note
The resulting vector will be projected on the horizontal plane

◆ operator==()

template<typename T >
bool PolarOf::operator== ( const PolarOf< T > &  v) const

Equality test to another vector.

Parameters
vThe vector to check against
Returns
true: if it is identical to the given vector
Note
This uses float comparison to check equality which may have strange effects. Equality on floats should be avoided.

◆ Magnitude()

template<typename T >
static float Passer::LinearAlgebra::PolarOf< T >::Magnitude ( const PolarOf< T > &  v)
inlinestatic

The vector length.

Parameters
vThe vector for which you need the length
Returns
The vector length;

◆ magnitude()

template<typename T >
float Passer::LinearAlgebra::PolarOf< T >::magnitude ( ) const
inline

The vector length.

Returns
The vector length

◆ Normalize()

template<typename T >
PolarOf< T > PolarOf::Normalize ( const PolarOf< T > &  v)
static

Convert the vector to a length of 1.

Parameters
vThe vector to convert
Returns
The vector normalized to a length of 1

◆ normalized()

template<typename T >
PolarOf< T > PolarOf::normalized ( ) const

Convert the vector to a length of a.

Returns
The vector normalized to a length of 1

◆ operator-() [1/2]

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

Negate the vector.

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

◆ operator-() [2/2]

template<typename T >
PolarOf< T > PolarOf::operator- ( const PolarOf< T > &  v) const

Subtract a polar vector from this vector.

Parameters
vThe vector to subtract
Returns
The result of the subtraction

◆ operator+()

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

Add a polar vector to this vector.

Parameters
vThe vector to add
Returns
The result of the addition

◆ Distance()

template<typename T >
float PolarOf::Distance ( const PolarOf< T > &  v1,
const PolarOf< T > &  v2 
)
static

The distance between two vectors.

Parameters
v1The first vector
v2The second vector
Returns
The distance between the two vectors

◆ Rotate()

template<typename T >
PolarOf< T > PolarOf::Rotate ( const PolarOf< T > &  v,
AngleOf< T a 
)
static

Rotate a vector.

Parameters
vThe vector to rotate
aThe angle in degreesto rotate
Returns
The rotated vector

Friends And Related Symbol Documentation

◆ operator*

template<typename T >
PolarOf operator* ( const PolarOf< 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 >
PolarOf operator/ ( const PolarOf< 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

template<typename T >
float Passer::LinearAlgebra::PolarOf< T >::distance

The distance in meters.

Remarks
The distance shall never be negative

◆ angle

The angle in degrees clockwise rotation.

Remarks
The angle shall be between -180 .. 180

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