Normalize Spherical at creation
This commit is contained in:
parent
800eb75e28
commit
28ee2254b8
@ -5,54 +5,33 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
template <typename T>
|
||||
SphericalOf<T>::SphericalOf() {
|
||||
template <typename T> SphericalOf<T>::SphericalOf() {
|
||||
this->distance = 0.0f;
|
||||
this->direction = DirectionOf<T>();
|
||||
// this->horizontal = AngleOf<T>();
|
||||
// this->vertical = AngleOf<T>();
|
||||
}
|
||||
|
||||
// template <>
|
||||
// SphericalOf<signed short>::SphericalOf() {
|
||||
// this->distance = 0.0f;
|
||||
// this->horizontal = AngleOf<signed short>(0);
|
||||
// this->vertical = AngleOf<signed short>(0);
|
||||
// }
|
||||
|
||||
template <typename T>
|
||||
SphericalOf<T>::SphericalOf(float distance,
|
||||
AngleOf<T> horizontal,
|
||||
SphericalOf<T>::SphericalOf(float distance, AngleOf<T> horizontal,
|
||||
AngleOf<T> vertical) {
|
||||
if (distance < 0) {
|
||||
this->distance = distance;
|
||||
this->direction = DirectionOf<T>(horizontal, vertical);
|
||||
// this->horizontal = horizontal;
|
||||
// this->vertical = vertical;
|
||||
} else {
|
||||
this->distance = -distance;
|
||||
this->direction = -DirectionOf<T>(horizontal, vertical);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
SphericalOf<T>::SphericalOf(float distance, DirectionOf<T> direction) {
|
||||
if (distance < 0) {
|
||||
this->distance = -distance;
|
||||
this->direction = -direction;
|
||||
} else {
|
||||
this->distance = distance;
|
||||
this->direction = direction;
|
||||
}
|
||||
|
||||
// template <>
|
||||
// SphericalOf<float>::SphericalOf(float distance,
|
||||
// AngleOf<float> horizontal,
|
||||
// AngleOf<float> vertical) {
|
||||
// this->distance = distance;
|
||||
// this->horizontal = horizontal;
|
||||
// this->vertical = vertical;
|
||||
// }
|
||||
|
||||
// template <>
|
||||
// SphericalOf<signed short>::SphericalOf(float distance,
|
||||
// AngleOf<signed short> horizontal,
|
||||
// AngleOf<signed short> vertical) {
|
||||
// this->distance = distance;
|
||||
// this->horizontal = horizontal;
|
||||
// this->vertical = vertical;
|
||||
// }
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
SphericalOf<T> SphericalOf<T>::FromPolar(PolarOf<T> polar) {
|
||||
@ -62,8 +41,7 @@ SphericalOf<T> SphericalOf<T>::FromPolar(PolarOf<T> polar) {
|
||||
return r;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
SphericalOf<T> SphericalOf<T>::FromVector3(Vector3 v) {
|
||||
template <typename T> SphericalOf<T> SphericalOf<T>::FromVector3(Vector3 v) {
|
||||
float distance = v.magnitude();
|
||||
if (distance == 0.0f) {
|
||||
return SphericalOf(distance, AngleOf<T>(), AngleOf<T>());
|
||||
@ -76,8 +54,7 @@ SphericalOf<T> SphericalOf<T>::FromVector3(Vector3 v) {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector3 SphericalOf<T>::ToVector3() const {
|
||||
template <typename T> Vector3 SphericalOf<T>::ToVector3() const {
|
||||
float verticalRad = (pi / 2) - this->direction.vertical.InRadians();
|
||||
float horizontalRad = this->direction.horizontal.InRadians();
|
||||
|
||||
@ -122,8 +99,7 @@ SphericalOf<T> SphericalOf<T>::WithDistance(float distance) {
|
||||
return SphericalOf<T>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
SphericalOf<T> SphericalOf<T>::operator-() const {
|
||||
template <typename T> SphericalOf<T> SphericalOf<T>::operator-() const {
|
||||
SphericalOf<T> v = SphericalOf<T>(
|
||||
this->distance, this->direction.horizontal + AngleOf<T>::Degrees(180),
|
||||
this->direction.vertical + AngleOf<T>::Degrees(180));
|
||||
@ -206,14 +182,12 @@ SphericalOf<T> SphericalOf<T>::operator+=(const SphericalOf<T>& v) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
SphericalOf<T> SphericalOf<T>::operator*=(float f) {
|
||||
template <typename T> SphericalOf<T> SphericalOf<T>::operator*=(float f) {
|
||||
this->distance *= f;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
SphericalOf<T> SphericalOf<T>::operator/=(float f) {
|
||||
template <typename T> SphericalOf<T> SphericalOf<T>::operator/=(float f) {
|
||||
this->distance /= f;
|
||||
return *this;
|
||||
}
|
||||
@ -256,8 +230,7 @@ AngleOf<T> SphericalOf<T>::AngleBetween(const SphericalOf& v1,
|
||||
|
||||
template <typename T>
|
||||
AngleOf<T> Passer::LinearAlgebra::SphericalOf<T>::SignedAngleBetween(
|
||||
const SphericalOf<T>& v1,
|
||||
const SphericalOf<T>& v2,
|
||||
const SphericalOf<T> &v1, const SphericalOf<T> &v2,
|
||||
const SphericalOf<T> &axis) {
|
||||
Vector3 v1_vector = v1.ToVector3();
|
||||
Vector3 v2_vector = v2.ToVector3();
|
||||
|
Loading…
x
Reference in New Issue
Block a user