RoboidControl for Arduino
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Polar Struct Reference

A polar vector. More...

#include <Polar.h>

Public Member Functions

 Polar ()
 Create a new polar vector with zero degrees and distance.
 
 Polar (float angle, float distance)
 Create a new polar vector.
 
Polar operator- ()
 Negate the polar vector.
 
Polar operator- (const Polar &v) const
 Substract a polar vector from this coordinate.
 
Polar operator+ (const Polar &v) const
 Add another polar vector to this polar vector.
 
Polar operator* (float factor) const
 Scale the vector uniformly up.
 
Polar operator/ (const float &factor)
 Scale the vector uniformly down.
 

Static Public Member Functions

static float Distance (const Polar &v1, const Polar &v2)
 The distance between two vectors.
 
static Polar Rotate (Polar v, float angle)
 Rotate the vector.
 

Public Attributes

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

Static Public Attributes

static const Polar zero = Polar(0, 0)
 A polar vector with zero degrees and distance.
 

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/2]

Polar::Polar ( )

Create a new polar vector with zero degrees and distance.

◆ Polar() [2/2]

Polar::Polar ( float  angle,
float  distance 
)

Create a new polar vector.

Parameters
angleThe angle in degrees, clockwise rotation
distanceThe distance in meters

Member Function Documentation

◆ operator-() [1/2]

Polar Polar::operator- ( )

Negate the polar vector.

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

Returns
The negated vector

◆ operator-() [2/2]

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

Substract a polar vector from this coordinate.

Parameters
vThe vector to subtract from this vector
Returns
The result of the subtraction

◆ operator+()

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

Add another polar vector to this polar vector.

Parameters
vThe vector to add
Returns
The result of adding the vector

◆ operator*()

Polar Polar::operator* ( float  factor) const

Scale the vector uniformly up.

Parameters
factorThe scaling factor
Returns
The scaled vector

This operation will scale the distance of the vector. The angle will be unaffected.

◆ operator/()

Polar Polar::operator/ ( const float &  factor)

Scale the vector uniformly down.

Parameters
factorThe scaling factor
Returns
The scaled vector

This operation will scale the distance of the vector. The angle will be unaffected.

◆ 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 ( Polar  v,
float  angle 
)
static

Rotate the vector.

Parameters
vThe vector to rotate
angleAngle in radias to rotate
Returns
The rotated vector

Member Data Documentation

◆ angle

float Polar::angle

The angle in degrees, clockwise rotation.

The angle is normalized to -180 .. 180

◆ distance

float Polar::distance

The distance in meters.

The distance should never be negative

◆ zero

const Polar Polar::zero = Polar(0, 0)
static

A polar vector with zero degrees and distance.


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