Add conversion from Spherical

This commit is contained in:
Pascal Serrarens 2024-04-19 12:16:20 +02:00
parent 66ff721dfe
commit c274c3eac9
2 changed files with 7 additions and 0 deletions

View File

@ -2,6 +2,7 @@
#include "Angle.h"
#include "Polar.h"
#include "Spherical.h"
Polar::Polar() {
angle = 0.0F;
@ -26,6 +27,11 @@ Polar::Polar(Vector2 v) {
distance = v.magnitude();
}
Polar::Polar(Spherical s) {
angle = s.horizontalAngle;
distance = s.distance * cosf(s.verticalAngle * Angle::Deg2Rad);
}
const Polar Polar::zero = Polar(0, 0);
float Polar::Distance(const Polar &v1, const Polar &v2) {

View File

@ -37,6 +37,7 @@ public:
Polar(float angle, float distance);
Polar(Vector2 v);
Polar(Spherical s);
/// <summary>
/// A polar vector with zero degrees and distance