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

A spherical vector. More...

#include <Spherical.h>

Public Member Functions

 Spherical ()
 Create a new spherical vector with zero degrees and distance.
 
 Spherical (float distance, Angle horizontalAngle, Angle verticalAngle)
 Create a new spherical vector.
 
 Spherical (Polar polar)
 Convert polar coordinates to spherical coordinates.
 
 Spherical (Vector3 v)
 Convert 3D carthesian coordinates to spherical coordinates.
 
bool operator== (const Spherical &v) const
 Equality test to another vector.
 
float magnitude () const
 The vector length.
 
Spherical normalized () const
 Convert the vector to a length of a.
 
Spherical operator- () const
 Negate the vector.
 
Spherical operator*= (float f)
 
Spherical operator/= (float f)
 

Static Public Member Functions

static float Magnitude (const Spherical &v)
 The vector length.
 
static Spherical Normalize (const Spherical &v)
 Convert the vector to a length of 1.
 
static Spherical Rotate (const Spherical &v, Angle horizontalAngle, Angle verticalAngle)
 The distance between two vectors.
 
static Spherical RotateHorizontal (const Spherical &v, Angle angle)
 
static Spherical RotateVertical (const Spherical &v, Angle angle)
 

Public Attributes

float distance
 The distance in meters.
 
Angle horizontalAngle
 The angle in the horizontal plane in degrees, clockwise rotation.
 
Angle verticalAngle
 The angle in the vertical plane in degrees. Positive is upward.
 

Static Public Attributes

static const Spherical zero = Spherical(0.0f, 0.0f, 0.0f)
 A spherical vector with zero degree angles and distance.
 
static const Spherical forward = Spherical(1.0f, 0.0f, 0.0f)
 A normalized forward-oriented vector.
 
static const Spherical back = Spherical(1.0f, 180.0f, 0.0f)
 A normalized back-oriented vector.
 
static const Spherical right = Spherical(1.0f, 90.0f, 0.0f)
 A normalized right-oriented vector.
 
static const Spherical left = Spherical(1.0f, -90.0f, 0.0f)
 A normalized left-oriented vector.
 
static const Spherical up = Spherical(1.0f, 0.0f, 90.0f)
 A normalized up-oriented vector.
 
static const Spherical down = Spherical(1.0f, 0.0f, -90.0f)
 A normalized down-oriented vector.
 

Friends

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

Detailed Description

A spherical vector.

This is a vector in 3D space using a spherical coordinate system. It consists of a distance and the polar and elevation angles from a reference direction. The reference direction is typically thought of as a forward direction.

Constructor & Destructor Documentation

◆ Spherical() [1/4]

Spherical::Spherical ( )

Create a new spherical vector with zero degrees and distance.

◆ Spherical() [2/4]

Spherical::Spherical ( float  distance,
Angle  horizontalAngle,
Angle  verticalAngle 
)

Create a new spherical vector.

Parameters
distanceThe distance in meters
horizontalAngleThe angle in the horizontal plane in degrees, clockwise rotation
verticalAngleThe angle in the vertical plan in degrees, zero is forward, positive is upward

◆ Spherical() [3/4]

Spherical::Spherical ( Polar  polar)

Convert polar coordinates to spherical coordinates.

Parameters
polarThe polar coordinate

◆ Spherical() [4/4]

Spherical::Spherical ( Vector3  v)

Convert 3D carthesian coordinates to spherical coordinates.

Parameters
vVector in 3D carthesian coordinates;

Member Function Documentation

◆ operator==()

bool Spherical::operator== ( const Spherical 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::Spherical::Magnitude ( const Spherical v)
inlinestatic

The vector length.

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

◆ magnitude()

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

The vector length.

Returns
The vector length

◆ Normalize()

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

Spherical Spherical::normalized ( ) const

Convert the vector to a length of a.

Returns
The vector normalized to a length of 1

◆ operator-()

Spherical Spherical::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*=()

Spherical Spherical::operator*= ( float  f)

◆ operator/=()

Spherical Spherical::operator/= ( float  f)

◆ Rotate()

Spherical Spherical::Rotate ( const Spherical v,
Angle  horizontalAngle,
Angle  verticalAngle 
)
static

The distance between two vectors.

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

◆ RotateHorizontal()

Spherical Spherical::RotateHorizontal ( const Spherical v,
Angle  angle 
)
static

◆ RotateVertical()

Spherical Spherical::RotateVertical ( const Spherical v,
Angle  angle 
)
static

Friends And Related Symbol Documentation

◆ operator* [1/2]

Spherical operator* ( const Spherical 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]

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

◆ operator/ [1/2]

Spherical operator/ ( const Spherical 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]

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

Member Data Documentation

◆ distance

float Passer::LinearAlgebra::Spherical::distance

The distance in meters.

Remarks
The distance should never be negative

◆ horizontalAngle

Angle Passer::LinearAlgebra::Spherical::horizontalAngle

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

The angle is automatically normalized to -180 .. 180

◆ verticalAngle

Angle Passer::LinearAlgebra::Spherical::verticalAngle

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

The angle is automatically normalized to -180 .. 180

◆ zero

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

A spherical vector with zero degree angles and distance.

◆ forward

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

A normalized forward-oriented vector.

◆ back

const Spherical Spherical::back = Spherical(1.0f, 180.0f, 0.0f)
static

A normalized back-oriented vector.

◆ right

const Spherical Spherical::right = Spherical(1.0f, 90.0f, 0.0f)
static

A normalized right-oriented vector.

◆ left

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

A normalized left-oriented vector.

◆ up

const Spherical Spherical::up = Spherical(1.0f, 0.0f, 90.0f)
static

A normalized up-oriented vector.

◆ down

const Spherical Spherical::down = Spherical(1.0f, 0.0f, -90.0f)
static

A normalized down-oriented vector.


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