Added spherical <-> polar convertions
This commit is contained in:
parent
7ece8abd02
commit
276d293c9b
@ -19,6 +19,12 @@ Spherical::Spherical() {
|
|||||||
// this->distance = distance;
|
// this->distance = distance;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
Spherical::Spherical(Polar polar) {
|
||||||
|
this->horizontalAngle = polar.angle;
|
||||||
|
this->verticalAngle = 0.0F;
|
||||||
|
this->magnitude = polar.distance;
|
||||||
|
}
|
||||||
|
|
||||||
Spherical::Spherical(float distance, Angle horizontalAngle, Angle verticalAngle)
|
Spherical::Spherical(float distance, Angle horizontalAngle, Angle verticalAngle)
|
||||||
: magnitude(distance), horizontalAngle(horizontalAngle),
|
: magnitude(distance), horizontalAngle(horizontalAngle),
|
||||||
verticalAngle(verticalAngle) {}
|
verticalAngle(verticalAngle) {}
|
||||||
@ -37,4 +43,8 @@ float Spherical::GetSwing() {
|
|||||||
// Not sure if this is correct
|
// Not sure if this is correct
|
||||||
return sqrtf(horizontalAngle * horizontalAngle +
|
return sqrtf(horizontalAngle * horizontalAngle +
|
||||||
verticalAngle * verticalAngle);
|
verticalAngle * verticalAngle);
|
||||||
|
}
|
||||||
|
|
||||||
|
Polar Spherical::ProjectOnHorizontalPlane() {
|
||||||
|
Polar(horizontalAngle, magnitude);
|
||||||
}
|
}
|
@ -7,6 +7,7 @@
|
|||||||
#define SPHERICAL_H
|
#define SPHERICAL_H
|
||||||
|
|
||||||
#include "Angle.h"
|
#include "Angle.h"
|
||||||
|
#include "Polar.h"
|
||||||
|
|
||||||
struct Vector3;
|
struct Vector3;
|
||||||
|
|
||||||
@ -41,6 +42,10 @@ public:
|
|||||||
|
|
||||||
Spherical(float distance, Angle horizontalAngle, Angle verticalAngle);
|
Spherical(float distance, Angle horizontalAngle, Angle verticalAngle);
|
||||||
|
|
||||||
|
/// @brief Convert polar coordinates to spherical coordinates
|
||||||
|
/// @param polar The polar coordinate
|
||||||
|
Spherical(Polar polar);
|
||||||
|
|
||||||
/// @brief Convert 3D carthesian coordinates to spherical coordinates
|
/// @brief Convert 3D carthesian coordinates to spherical coordinates
|
||||||
/// @param v Vector in 3D carthesian coordinates;
|
/// @param v Vector in 3D carthesian coordinates;
|
||||||
Spherical(Vector3 v);
|
Spherical(Vector3 v);
|
||||||
@ -49,6 +54,8 @@ public:
|
|||||||
const static Spherical zero;
|
const static Spherical zero;
|
||||||
|
|
||||||
float GetSwing();
|
float GetSwing();
|
||||||
|
|
||||||
|
Polar ProjectOnHorizontalPlane();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Passer
|
} // namespace Passer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user