AxisAngle FromQuaternion
This commit is contained in:
@@ -7,8 +7,16 @@ namespace AxisAngleTests {
|
||||
inline void Define() {
|
||||
using namespace jtest;
|
||||
|
||||
AxisAngleUnit += Test("Not Implemented", [] {
|
||||
throw("Not Implemented");
|
||||
AxisAngleUnit += Test("From_Quaternion", [] {
|
||||
AxisAngle expected_result({0.3860166, 0.4380138, 0.8118714}, 0.6742209);
|
||||
Quaternion q(0.1276794, 0.1448781, 0.2685358, 0.9437144);
|
||||
|
||||
AxisAngle from_quaternion(q);
|
||||
|
||||
jtest::check(Math::EqualAbs(expected_result.axis.x, from_quaternion.axis.x, 1e-6f));
|
||||
jtest::check(Math::EqualAbs(expected_result.axis.y, from_quaternion.axis.y, 1e-6f));
|
||||
jtest::check(Math::EqualAbs(expected_result.axis.z, from_quaternion.axis.z, 1e-6f));
|
||||
jtest::check(Math::EqualAbs(expected_result.angle, from_quaternion.angle, 1e-6f));
|
||||
});
|
||||
}
|
||||
inline void Run() {
|
||||
|
@@ -9,6 +9,9 @@
|
||||
|
||||
jtest::Unit QuaternionUnit {"Quaternion"};
|
||||
namespace QuaternionTests {
|
||||
|
||||
// This is here to check the accuracy of the Slerp inside the Quaternion class.
|
||||
// Although you don't jtest::check anything :shrug: - Redacted.
|
||||
Quaternion PreciseSlerp(const Quaternion &a, const Quaternion& b, float t)
|
||||
{
|
||||
double angle = a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
|
||||
@@ -80,6 +83,18 @@ namespace QuaternionTests {
|
||||
jtest::check(Math::EqualAbs(expected_result.z, from_euler.z, 1e-6f));
|
||||
jtest::check(Math::EqualAbs(expected_result.w, from_euler.w, 1e-6f));
|
||||
});
|
||||
|
||||
QuaternionUnit += Test("From_AxisAngle", [] {
|
||||
Quaternion expected_result(0.0579133, 0.0782044, 0.1765667, 0.9794664);
|
||||
AxisAngle a({0.2872573, 0.3879036, 0.8757934}, 0.4059981);
|
||||
Quaternion from_axis(a);
|
||||
|
||||
jtest::check(Math::EqualAbs(expected_result.x, from_axis.x, 1e-6f));
|
||||
jtest::check(Math::EqualAbs(expected_result.y, from_axis.y, 1e-6f));
|
||||
jtest::check(Math::EqualAbs(expected_result.z, from_axis.z, 1e-6f));
|
||||
jtest::check(Math::EqualAbs(expected_result.w, from_axis.w, 1e-6f));
|
||||
});
|
||||
|
||||
QuaternionUnit += Test("Mat4x4Conversion", [] { throw("Not Implemented"); });
|
||||
QuaternionUnit += Test("MulOpQuat", [] { throw("Not Implemented"); });
|
||||
QuaternionUnit += Test("DivOpQuat", [] { throw("Not Implemented"); });
|
||||
|
Reference in New Issue
Block a user