This commit is contained in:
Pascal Serrarens 2024-12-28 10:04:04 +01:00
parent 89a57114a4
commit 94a3105a61
6 changed files with 2 additions and 225 deletions

View File

@ -1,45 +0,0 @@
/*
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0.If a copy of the MPL was not distributed with this
// file, You can obtain one at https ://mozilla.org/MPL/2.0/.
#ifndef ANGLEAXIS_H
#define ANGLEAXIS_H
#include "Angle.h"
#include "Direction.h"
#include "Quaternion.h"
namespace Passer {
namespace LinearAlgebra {
// Isn't this the same as SphericalOf<T> ?????????????
template <typename T>
class AngleAxisOf {
public:
float angle;
DirectionOf<T> axis;
AngleAxisOf();
AngleAxisOf(float angle, DirectionOf<T> axis);
AngleAxisOf(Quaternion q);
AngleAxisOf(float angle, Vector3 axis);
const static AngleAxisOf<T> zero;
Quaternion ToQuaternion();
DirectionOf<T> GetSwing();
};
using AngleAxisSingle = AngleAxisOf<float>;
using AngleAxis16 = AngleAxisOf<signed short>;
using AngleAxis = AngleAxisOf<float>;
} // namespace LinearAlgebra
} // namespace Passer
using namespace Passer::LinearAlgebra;
#endif
*/

View File

@ -1,41 +0,0 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0.If a copy of the MPL was not distributed with this
// file, You can obtain one at https ://mozilla.org/MPL/2.0/.
/*
#include "Axis.h"
#include "Quaternion.h"
#include "Vector3.h"
#include <math.h>
Axis::Axis() {
horizontalAngle = Angle();
verticalAngle = Angle();
}
Axis::Axis(Angle horizontal, Angle vertical) {
this->horizontalAngle = horizontal;
this->verticalAngle = vertical;
};
Axis::Axis(Vector3 v) {
this->horizontalAngle =
atan2f(v.Right(), v.Forward()) * Passer::LinearAlgebra::Rad2Deg;
this->verticalAngle = 90 - acosf(v.Up()) * Passer::LinearAlgebra::Rad2Deg;
}
const Axis Axis::forward = Axis(0.0f, 0.0f);
const Axis Axis::back = Axis(180.0f, 0.0f);
const Axis Axis::up = Axis(0.0f, 90.0f);
const Axis Axis::down = Axis(0.0f, -90.0f);
const Axis Axis::left = Axis(-90.0f, 0.0f);
const Axis Axis::right = Axis(90.0f, 0.0f);
Vector3 Axis::ToVector3() {
Vector3 v = Quaternion::Euler(-(this->verticalAngle.ToFloat()),
this->horizontalAngle.ToFloat(), 0) *
Vector3::forward;
return v;
}
*/

39
Axis.h
View File

@ -1,39 +0,0 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0.If a copy of the MPL was not distributed with this
// file, You can obtain one at https ://mozilla.org/MPL/2.0/.
/*
#ifndef AXIS_H
#define AXIS_H
#include "Angle.h"
namespace Passer {
namespace LinearAlgebra {
struct Vector3;
class Axis {
public:
Angle horizontalAngle;
Angle verticalAngle;
Axis();
Axis(Angle horizontal, Angle vertical);
Axis(Vector3 v);
const static Axis forward;
const static Axis back;
const static Axis up;
const static Axis down;
const static Axis left;
const static Axis right;
Vector3 ToVector3();
};
} // namespace LinearAlgebra
} // namespace Passer
using namespace Passer::LinearAlgebra;
#endif
*/

View File

@ -32,8 +32,8 @@ else()
"Polar.cpp"
"Spherical.cpp"
"Matrix.cpp"
"Axis.cpp"
"AngleAxis.cpp"
# "Axis.cpp"
# "AngleAxis.cpp"
"SwingTwist.cpp"
"Direction.cpp"
)

View File

@ -1,48 +0,0 @@
#include "Range.h"
/*
Range16::Range16() { this->range = 0; }
Range16::Range16(float f) {
// clamp the float range to -1..1
if (f < -1.0F)
f = -1.0F;
else if (f > 1.0F)
f = 1.0F;
// map -1..1 to 0..65535
this->range = (unsigned short)((f + 1.0F) * 65535.0F);
}
Range16::Range16(short s) {
// clamp the range to -32767..32767
// This is needed because the representation can support +/-32768 (like 2s
// complement)
if (s < -32767)
s = -32767;
else if (s > 32767)
s = 32767;
this->range = (unsigned short)(s + 32767);
}
Range16 Range16::operator-(Range16 a) { this->range - a.range; };
Range16 Range16::operator+(Range16 a) { this->range + a.range; };
Range16 &Range16::operator-() { -this->range; }
bool Range16::operator==(Range16 a) { this->range == a.range; }
bool Range16::operator!=(Range16 a) { return (this->range != a.range); }
bool Range16::operator<(Range16 a) { return (this->range < a.range); }
bool Range16::operator>(Range16 a) { return (this->range > a.range); }
bool Range16::operator<=(Range16 a) { return (this->range <= a.range); }
bool Range16::operator>=(Range16 a) { return (this->range >= a.range); }
*/
template <> RangeUsing<unsigned char>::RangeUsing(float f) {
this->value = (unsigned char)((f + 1.0f) * 127.0F);
}
template <> RangeUsing<unsigned short>::RangeUsing(float f) {
this->value = (unsigned short)((f + 1.0F) * 32767.0F);
}

50
Range.h
View File

@ -1,50 +0,0 @@
#ifndef RANGE_H
#define RANGE_H
namespace Passer {
namespace LinearAlgebra {
/*
/// @brief Signed range. May be renamed to SignedRange later
class Range16 {
public:
Range16();
Range16(float range); // range -1..1
Range16(short range); // range -32768..32767
inline Range16 operator-(Range16 a);
inline Range16 operator+(Range16 a);
inline virtual Range16 &operator-();
inline bool operator==(Range16 a);
inline bool operator!=(Range16 a);
inline bool operator<(Range16 a);
inline bool operator>(Range16 a);
inline bool operator<=(Range16 a);
inline bool operator>=(Range16 a);
protected:
// How do we make sure we have 16 bit range on every platform?
// uint16_t range; // 16-bit range
unsigned short range; // 16-bit range
};
*/
template <typename T> class RangeUsing {
public:
RangeUsing<T>(float range); // range -1..1
inline RangeUsing<T> operator-(RangeUsing<T> a) { this->value - a.value; }
inline RangeUsing<T> operator+(RangeUsing<T> a) { this->value + a.value; }
inline RangeUsing<T> operator-() { this->value = -this.value; }
inline T GetValue() { return value; }
T value;
};
} // namespace LinearAlgebra
} // namespace Passer
using namespace Passer::LinearAlgebra;
#endif