RoboidControl
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
Passer::LinearAlgebra::Polar Struct Reference

A polar vector. More...

#include <Polar.h>

Public Member Functions

 Polar ()
 A new vector with polar coordinates with zero degrees and distance.
 
 Polar (float distance, Angle angle)
 A new vector with polar coordinates.
 
 Polar (Vector2 v)
 Convert a vector from 2D carthesian coordinates to polar coordinates.
 
 Polar (Spherical s)
 Convert a vector from spherical coordinates to polar coordinates.
 
bool operator== (const Polar &v) const
 Equality test to another vector.
 
float magnitude () const
 The vector length.
 
Polar normalized () const
 Convert the vector to a length of a.
 
Polar operator- () const
 Negate the vector.
 
Polar operator- (const Polar &v) const
 Subtract a polar vector from this vector.
 
Polar operator-= (const Polar &v)
 
Polar operator+ (const Polar &v) const
 Add a polar vector to this vector.
 
Polar operator+= (const Polar &v)
 
Polar operator*= (float f)
 
Polar operator/= (float f)
 

Static Public Member Functions

static float Magnitude (const Polar &v)
 The vector length.
 
static Polar Normalize (const Polar &v)
 Convert the vector to a length of 1.
 
static float Distance (const Polar &v1, const Polar &v2)
 The distance between two vectors.
 
static Polar Rotate (const Polar &v, Angle a)
 Rotate a vector.
 

Public Attributes

float distance
 The distance in meters.
 
Angle angle
 The angle in degrees clockwise rotation.
 

Static Public Attributes

static const Polar zero = Polar(0.0f, 0.0f)
 A polar vector with zero degrees and distance.
 
static const Polar forward = Polar(1.0f, 0.0f)
 A normalized forward-oriented vector.
 
static const Polar back = Polar(1.0, 180.0f)
 A normalized back-oriented vector.
 
static const Polar right = Polar(1.0, 90.0f)
 A normalized right-oriented vector.
 
static const Polar left = Polar(1.0, -90.0f)
 A normalized left-oriented vector.
 

Friends

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

Detailed Description

A polar vector.

This will use the polar coordinate system consisting of a angle from a reference direction and a distance.

Constructor & Destructor Documentation

◆ Polar() [1/4]

Polar::Polar ( )

A new vector with polar coordinates with zero degrees and distance.

◆ Polar() [2/4]

Polar::Polar ( float  distance,
Angle  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

◆ Polar() [3/4]

Polar::Polar ( Vector2  v)

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

Parameters
vThe vector to convert

◆ Polar() [4/4]

Passer::LinearAlgebra::Polar::Polar ( Spherical  s)

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

Member Function Documentation

◆ operator==()

bool Polar::operator== ( const Polar 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()

static float Passer::LinearAlgebra::Polar::Magnitude ( const Polar v)
inlinestatic

The vector length.

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

◆ magnitude()

float Passer::LinearAlgebra::Polar::magnitude ( ) const
inline

The vector length.

Returns
The vector length

◆ Normalize()

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

Polar Polar::normalized ( ) const

Convert the vector to a length of a.

Returns
The vector normalized to a length of 1

◆ operator-() [1/2]

Polar Polar::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]

Polar Polar::operator- ( const Polar v) const

Subtract a polar vector from this vector.

Parameters
vThe vector to subtract
Returns
The result of the subtraction

◆ operator-=()

Polar Polar::operator-= ( const Polar v)

◆ operator+()

Polar Polar::operator+ ( const Polar v) const

Add a polar vector to this vector.

Parameters
vThe vector to add
Returns
The result of the addition

◆ operator+=()

Polar Polar::operator+= ( const Polar v)

◆ operator*=()

Polar Polar::operator*= ( float  f)

◆ operator/=()

Polar Polar::operator/= ( float  f)

◆ Distance()

float Polar::Distance ( const Polar v1,
const Polar v2 
)
static

The distance between two vectors.

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

◆ Rotate()

Polar Polar::Rotate ( const Polar v,
Angle  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* [1/2]

Polar operator* ( const Polar 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* [2/2]

Polar operator* ( float  f,
const Polar v 
)
friend

◆ operator/ [1/2]

Polar operator/ ( const Polar 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.

◆ operator/ [2/2]

Polar operator/ ( float  f,
const Polar v 
)
friend

Member Data Documentation

◆ distance

float Passer::LinearAlgebra::Polar::distance

The distance in meters.

Remarks
The distance shall never be negative

◆ angle

Angle Passer::LinearAlgebra::Polar::angle

The angle in degrees clockwise rotation.

Remarks
The angle shall be between -180 .. 180

◆ zero

const Polar Polar::zero = Polar(0.0f, 0.0f)
static

A polar vector with zero degrees and distance.

◆ forward

const Polar Polar::forward = Polar(1.0f, 0.0f)
static

A normalized forward-oriented vector.

◆ back

const Polar Polar::back = Polar(1.0, 180.0f)
static

A normalized back-oriented vector.

◆ right

const Polar Polar::right = Polar(1.0, 90.0f)
static

A normalized right-oriented vector.

◆ left

const Polar Polar::left = Polar(1.0, -90.0f)
static

A normalized left-oriented vector.


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