RoboidControl for Arduino
|
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. | |
A polar vector.
This will use the polar coordinate system consisting of a angle from a reference direction and a distance.
Polar::Polar | ( | ) |
Create a new polar vector with zero degrees and distance.
Polar::Polar | ( | float | angle, |
float | distance | ||
) |
Create a new polar vector.
angle | The angle in degrees, clockwise rotation |
distance | The distance in meters |
Polar Polar::operator- | ( | ) |
Negate the polar vector.
This will rotate the vector by 180 degrees. Distance will stay the same.
Substract a polar vector from this coordinate.
v | The vector to subtract from this vector |
Add another polar vector to this polar vector.
v | The vector to add |
Polar Polar::operator* | ( | float | factor | ) | const |
Scale the vector uniformly up.
factor | The scaling factor |
This operation will scale the distance of the vector. The angle will be unaffected.
Polar Polar::operator/ | ( | const float & | factor | ) |
Scale the vector uniformly down.
factor | The scaling factor |
This operation will scale the distance of the vector. The angle will be unaffected.
The distance between two vectors.
v1 | The first vector |
v2 | The second vector |
Rotate the vector.
v | The vector to rotate |
angle | Angle in radias to rotate |
float Polar::angle |
The angle in degrees, clockwise rotation.
The angle is normalized to -180 .. 180
float Polar::distance |
The distance in meters.
The distance should never be negative