diff --git a/include/Polar.h b/include/Polar.h index 468b35a..cbb161f 100644 --- a/include/Polar.h +++ b/include/Polar.h @@ -8,7 +8,8 @@ /// /// A polar vector /// -/// This will use the polar coordinate system consisting of a angle from a reference direction and a distance. +/// This will use the polar coordinate system consisting of a angle from a +/// reference direction and a distance. struct Polar { public: /// @@ -43,7 +44,7 @@ struct Polar { /// /// This will rotate the vector by 180 degrees. Distance will stay the same. /// The negated vector - + Polar operator-(); /// /// Substract a polar vector from this coordinate @@ -64,7 +65,8 @@ struct Polar { /// /// The scaling factor /// The scaled vector - /// This operation will scale the distance of the vector. The angle will be unaffected. + /// This operation will scale the distance of the vector. The angle will be + /// unaffected. Polar operator*(float factor) const; /// @@ -72,7 +74,8 @@ struct Polar { /// /// The scaling factor /// The scaled vector - /// This operation will scale the distance of the vector. The angle will be unaffected. + /// This operation will scale the distance of the vector. The angle will be + /// unaffected. Polar operator/(const float& factor); /// @@ -82,6 +85,14 @@ struct Polar { /// The second vector /// The distance between the two vectors static float Distance(const Polar& v1, const Polar& v2); + + /// + /// Rotate the vector + /// + /// The vector to rotate + /// Angle in radias to rotate + /// The rotated vector + static Polar Rotate(Polar v, float angle); }; #endif \ No newline at end of file diff --git a/src/Polar.cpp b/src/Polar.cpp index d9d15c0..7ba7ca1 100644 --- a/src/Polar.cpp +++ b/src/Polar.cpp @@ -66,3 +66,8 @@ Polar Polar::operator*(float f) const { Polar Polar::operator/(const float& f) { return Polar(this->angle, this->distance / f); } + +Polar Polar::Rotate(Polar v, float angle) { + v.angle += angle; + return v; +} \ No newline at end of file