Added Polar::Rotate
This commit is contained in:
parent
882dfdfcdb
commit
295a2b3902
@ -8,7 +8,8 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A polar vector
|
/// A polar vector
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// 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 {
|
struct Polar {
|
||||||
public:
|
public:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -43,7 +44,7 @@ struct Polar {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// This will rotate the vector by 180 degrees. Distance will stay the same.
|
/// This will rotate the vector by 180 degrees. Distance will stay the same.
|
||||||
/// <returns>The negated vector</returns>
|
/// <returns>The negated vector</returns>
|
||||||
|
|
||||||
Polar operator-();
|
Polar operator-();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Substract a polar vector from this coordinate
|
/// Substract a polar vector from this coordinate
|
||||||
@ -64,7 +65,8 @@ struct Polar {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="factor">The scaling factor</param>
|
/// <param name="factor">The scaling factor</param>
|
||||||
/// <returns>The scaled vector</returns>
|
/// <returns>The scaled vector</returns>
|
||||||
/// 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;
|
Polar operator*(float factor) const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -72,7 +74,8 @@ struct Polar {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="factor">The scaling factor</param>
|
/// <param name="factor">The scaling factor</param>
|
||||||
/// <returns>The scaled vector</returns>
|
/// <returns>The scaled vector</returns>
|
||||||
/// 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);
|
Polar operator/(const float& factor);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -82,6 +85,14 @@ struct Polar {
|
|||||||
/// <param name="v2">The second vector</param>
|
/// <param name="v2">The second vector</param>
|
||||||
/// <returns>The distance between the two vectors</returns>
|
/// <returns>The distance between the two vectors</returns>
|
||||||
static float Distance(const Polar& v1, const Polar& v2);
|
static float Distance(const Polar& v1, const Polar& v2);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rotate the vector
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="v">The vector to rotate</param>
|
||||||
|
/// <param name="angle">Angle in radias to rotate</param>
|
||||||
|
/// <returns>The rotated vector</returns>
|
||||||
|
static Polar Rotate(Polar v, float angle);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -66,3 +66,8 @@ Polar Polar::operator*(float f) const {
|
|||||||
Polar Polar::operator/(const float& f) {
|
Polar Polar::operator/(const float& f) {
|
||||||
return Polar(this->angle, this->distance / f);
|
return Polar(this->angle, this->distance / f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Polar Polar::Rotate(Polar v, float angle) {
|
||||||
|
v.angle += angle;
|
||||||
|
return v;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user