diff --git a/Polar.cpp b/Polar.cpp
index acdd506..c12ae96 100644
--- a/Polar.cpp
+++ b/Polar.cpp
@@ -35,20 +35,20 @@ Polar::Polar(Spherical s) {
const Polar Polar::zero = Polar(0, 0);
-float Polar::Distance(const Polar &v1, const Polar &v2) {
- float d =
- Angle::CosineRuleSide(v1.distance, v2.distance, v2.angle - v1.angle);
+float Polar::Distance(Polar &v1, Polar &v2) {
+ float d = Angle::CosineRuleSide(v1.distance, v2.distance,
+ (float)v2.angle - (float)v1.angle);
return d;
}
-Polar Polar::operator+(const Polar &v2) const {
+Polar Polar::operator+(Polar &v2) {
if (v2.distance == 0)
return Polar(this->distance,
this->angle); // Polar(this->angle, this->distance);
if (this->distance == 0)
return v2;
- float deltaAngle = Angle::Normalize(v2.angle - this->angle);
+ float deltaAngle = Angle::Normalize(v2.angle - (float)this->angle);
float rotation = deltaAngle < 0 ? 180 + deltaAngle : 180 - deltaAngle;
if (rotation == 180 && v2.distance > 0) {
@@ -64,24 +64,25 @@ Polar Polar::operator+(const Polar &v2) const {
float angle =
Angle::CosineRuleAngle(newDistance, this->distance, v2.distance);
- float newAngle = deltaAngle < 0 ? Angle::Normalize(this->angle - angle)
- : Angle::Normalize(this->angle + angle);
+ float newAngle =
+ deltaAngle < 0 ? (float)this->angle - angle : (float)this->angle + angle;
+ newAngle = Angle::Normalize(newAngle);
Polar vector = Polar(newDistance, newAngle); // Polar(newAngle, newDistance);
return vector;
}
Polar Polar::operator-() {
- Polar vector =
- Polar(this->distance,
- this->angle - 180); // Polar(this->angle - 180, this->distance);
+ Polar vector = Polar(this->distance,
+ (float)this->angle -
+ 180); // Polar(this->angle - 180, this->distance);
return vector;
}
-Polar Polar::operator-(const Polar &v2) const {
- Polar vector =
- *this + Polar(v2.distance,
- v2.angle - 180); //(Polar(v2.angle - 180, v2.distance));
- return vector;
+Polar Polar::operator-(Polar &v2) {
+ // Polar vector = *this + Polar(v2.distance, (float)v2.angle - 180);
+ //(Polar(v2.angle - 180, v2.distance));
+ Polar vector = -v2;
+ return *this + v2;
}
Polar Polar::operator*(float f) const {
@@ -94,7 +95,7 @@ Polar Polar::operator/(const float &f) {
this->angle); // Polar(this->angle, this->distance / f);
}
-Polar Polar::Rotate(Polar v, float angle) {
+Polar Polar::Rotate(Polar v, Angle angle) {
v.angle = Angle::Normalize(v.angle + angle);
return v;
}
\ No newline at end of file
diff --git a/Polar.h b/Polar.h
index 43b6c08..c77bb05 100644
--- a/Polar.h
+++ b/Polar.h
@@ -23,7 +23,7 @@ public:
/// The angle in degrees, clockwise rotation
///
/// The angle is normalized to -180 .. 180
- float angle;
+ Angle angle;
///
/// The distance in meters
///
@@ -70,14 +70,14 @@ public:
///
/// The vector to subtract from this vector
/// The result of the subtraction
- Polar operator-(const Polar &v) const;
+ Polar operator-(Polar &v);
///
/// Add another polar vector to this polar vector
///
/// The vector to add
/// The result of adding the vector
- Polar operator+(const Polar &v) const;
+ Polar operator+(Polar &v);
///
/// Scale the vector uniformly up
@@ -103,7 +103,7 @@ public:
/// The first vector
/// The second vector
/// The distance between the two vectors
- static float Distance(const Polar &v1, const Polar &v2);
+ static float Distance(Polar &v1, Polar &v2);
///
/// Rotate the vector
@@ -111,7 +111,7 @@ public:
/// The vector to rotate
/// Angle in radias to rotate
/// The rotated vector
- static Polar Rotate(Polar v, float angle);
+ static Polar Rotate(Polar v, Angle angle);
};
} // namespace Passer
#include "Spherical.h"