Added some more Quaternion unit tests
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m17s
Build Docs With Doxygen / Explore-Gitea-Actions (push) Successful in 28s

This commit is contained in:
2025-03-04 16:32:12 -06:00
parent 28f87dd189
commit 0f5070783e
2 changed files with 15 additions and 2 deletions

View File

@@ -126,7 +126,6 @@ namespace J3ML::LinearAlgebra {
Quaternion::Quaternion(float X, float Y, float Z, float W) : x(X), y(Y), z(Z), w(W) {}
// TODO: implement
float Quaternion::Dot(const Quaternion &rhs) const {
return x * rhs.x + y * rhs.y + z * rhs.z + w * rhs.w;
}

View File

@@ -5,6 +5,7 @@
#include <jtest/Unit.hpp>
#include <J3ML/LinearAlgebra/Quaternion.hpp>
#include <J3ML/Algorithm/RNG.hpp>
#include <J3ML/Math.hpp>
jtest::Unit QuaternionUnit {"Quaternion"};
namespace QuaternionTests {
@@ -73,6 +74,12 @@ namespace QuaternionTests {
}
});
QuaternionUnit += Test("Constants", [] {
Quaternion id {0.f, 0.f, 0.f, 1.f};
jtest::check(id.Equals(Quaternion::Identity));
});
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);
@@ -115,7 +122,14 @@ namespace QuaternionTests {
//Quaternion a =
});
QuaternionUnit += Test("DivOpQuat", [] { throw("Not Implemented"); });
QuaternionUnit += Test("Lerp", [] { throw("Not Implemented"); });
QuaternionUnit += Test("Lerp", [] {
Quaternion a = Quaternion::RotateX(Math::PiOverTwo);
Quaternion b = Quaternion::RotateX(-Math::PiOverTwo);
Quaternion expected {0,0,0,0};
Quaternion result = a.Lerp(b, 0.5f);
});
QuaternionUnit += Test("RotateFromTo", [] { throw("Not Implemented"); });
QuaternionUnit += Test("Transform", [] { throw("Not Implemented"); });
}