RoboidControl for Arduino
Loading...
Searching...
No Matches
Polar.h
Go to the documentation of this file.
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0.If a copy of the MPL was not distributed with this
3// file, You can obtain one at https ://mozilla.org/MPL/2.0/.
4
5#ifndef POLAR_H
6#define POLAR_H
7
13struct Polar {
14 public:
19 float angle;
24 float distance;
25
29 Polar();
35 Polar(float angle, float distance);
36
40 const static Polar zero;
41
47
54 Polar operator-(const Polar& v) const;
55
61 Polar operator+(const Polar& v) const;
62
70 Polar operator*(float factor) const;
71
79 Polar operator/(const float& factor);
80
87 static float Distance(const Polar& v1, const Polar& v2);
88
95 static Polar Rotate(Polar v, float angle);
96};
97
98#endif
A polar vector.
Definition Polar.h:13
Polar operator/(const float &factor)
Scale the vector uniformly down.
Definition Polar.cpp:70
float angle
The angle in degrees, clockwise rotation.
Definition Polar.h:19
static const Polar zero
A polar vector with zero degrees and distance.
Definition Polar.h:40
Polar operator-()
Negate the polar vector.
Definition Polar.cpp:56
static float Distance(const Polar &v1, const Polar &v2)
The distance between two vectors.
Definition Polar.cpp:24
Polar operator*(float factor) const
Scale the vector uniformly up.
Definition Polar.cpp:66
Polar operator+(const Polar &v) const
Add another polar vector to this polar vector.
Definition Polar.cpp:30
static Polar Rotate(Polar v, float angle)
Rotate the vector.
Definition Polar.cpp:74
Polar()
Create a new polar vector with zero degrees and distance.
Definition Polar.cpp:6
float distance
The distance in meters.
Definition Polar.h:24