Swapped polar constructor param order
This commit is contained in:
parent
e5f8d73e19
commit
8a2ce21abc
26
Polar.cpp
26
Polar.cpp
@ -9,7 +9,8 @@ Polar::Polar() {
|
|||||||
distance = 0.0F;
|
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
|
// distance should always be 0 or greater
|
||||||
if (newDistance < 0) {
|
if (newDistance < 0) {
|
||||||
angle = Angle::Normalize(newAngle - 180);
|
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 {
|
Polar Polar::operator+(const Polar &v2) const {
|
||||||
if (v2.distance == 0)
|
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)
|
if (this->distance == 0)
|
||||||
return v2;
|
return v2;
|
||||||
|
|
||||||
@ -51,7 +53,9 @@ Polar Polar::operator+(const Polar &v2) const {
|
|||||||
|
|
||||||
if (rotation == 180 && v2.distance > 0) {
|
if (rotation == 180 && v2.distance > 0) {
|
||||||
// angle is too small, take this angle and add the distances
|
// 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 =
|
float newDistance =
|
||||||
@ -62,26 +66,32 @@ Polar Polar::operator+(const Polar &v2) const {
|
|||||||
|
|
||||||
float newAngle = deltaAngle < 0 ? Angle::Normalize(this->angle - angle)
|
float newAngle = deltaAngle < 0 ? Angle::Normalize(this->angle - angle)
|
||||||
: 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;
|
return vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
Polar Polar::operator-() {
|
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;
|
return vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
Polar Polar::operator-(const Polar &v2) const {
|
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;
|
return vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
Polar Polar::operator*(float f) const {
|
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) {
|
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) {
|
Polar Polar::Rotate(Polar v, float angle) {
|
||||||
|
5
Polar.h
5
Polar.h
@ -5,6 +5,8 @@
|
|||||||
#ifndef POLAR_H
|
#ifndef POLAR_H
|
||||||
#define POLAR_H
|
#define POLAR_H
|
||||||
|
|
||||||
|
#include "Angle.h"
|
||||||
|
|
||||||
namespace Passer {
|
namespace Passer {
|
||||||
|
|
||||||
struct Vector2;
|
struct Vector2;
|
||||||
@ -37,7 +39,8 @@ public:
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="angle">The angle in degrees, clockwise rotation</param>
|
/// <param name="angle">The angle in degrees, clockwise rotation</param>
|
||||||
/// <param name="distance">The distance in meters</param>
|
/// <param name="distance">The distance in meters</param>
|
||||||
Polar(float angle, float distance);
|
// Polar(float angle, float distance);
|
||||||
|
Polar(float distance, Angle angle);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert a Vector2 to a Polar coordinate
|
/// Convert a Vector2 to a Polar coordinate
|
||||||
|
Loading…
x
Reference in New Issue
Block a user