diff --git a/Polar.cpp b/Polar.cpp index 421962e..acdd506 100644 --- a/Polar.cpp +++ b/Polar.cpp @@ -9,7 +9,8 @@ Polar::Polar() { distance = 0.0F; } -Polar::Polar(float newAngle, float newDistance) { +// Polar::Polar(float newAngle, float newDistance) { +Polar::Polar(float newDistance, Angle newAngle) { // distance should always be 0 or greater if (newDistance < 0) { angle = Angle::Normalize(newAngle - 180); @@ -42,7 +43,8 @@ float Polar::Distance(const Polar &v1, const Polar &v2) { Polar Polar::operator+(const Polar &v2) const { if (v2.distance == 0) - return Polar(this->angle, this->distance); + return Polar(this->distance, + this->angle); // Polar(this->angle, this->distance); if (this->distance == 0) return v2; @@ -51,7 +53,9 @@ Polar Polar::operator+(const Polar &v2) const { if (rotation == 180 && v2.distance > 0) { // angle is too small, take this angle and add the distances - return Polar(this->angle, this->distance + v2.distance); + return Polar( + this->distance + v2.distance, + this->angle); // Polar(this->angle, this->distance + v2.distance); } float newDistance = @@ -62,26 +66,32 @@ Polar Polar::operator+(const Polar &v2) const { float newAngle = deltaAngle < 0 ? Angle::Normalize(this->angle - angle) : Angle::Normalize(this->angle + angle); - Polar vector = Polar(newAngle, newDistance); + Polar vector = Polar(newDistance, newAngle); // Polar(newAngle, newDistance); return vector; } Polar Polar::operator-() { - Polar vector = Polar(this->angle - 180, this->distance); + Polar vector = + Polar(this->distance, + this->angle - 180); // Polar(this->angle - 180, this->distance); return vector; } Polar Polar::operator-(const Polar &v2) const { - Polar vector = *this + (Polar(v2.angle - 180, v2.distance)); + Polar vector = + *this + Polar(v2.distance, + v2.angle - 180); //(Polar(v2.angle - 180, v2.distance)); return vector; } Polar Polar::operator*(float f) const { - return Polar(this->angle, this->distance * f); + return Polar(this->distance * f, + this->angle); // Polar(this->angle, this->distance * f); } Polar Polar::operator/(const float &f) { - return Polar(this->angle, this->distance / f); + return Polar(this->distance / f, + this->angle); // Polar(this->angle, this->distance / f); } Polar Polar::Rotate(Polar v, float angle) { diff --git a/Polar.h b/Polar.h index 9e2c8ca..43b6c08 100644 --- a/Polar.h +++ b/Polar.h @@ -5,6 +5,8 @@ #ifndef POLAR_H #define POLAR_H +#include "Angle.h" + namespace Passer { struct Vector2; @@ -37,7 +39,8 @@ public: /// /// The angle in degrees, clockwise rotation /// The distance in meters - Polar(float angle, float distance); + // Polar(float angle, float distance); + Polar(float distance, Angle angle); /// /// Convert a Vector2 to a Polar coordinate