Added some more Quaternion unit tests
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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"); });
|
||||
}
|
||||
|
Reference in New Issue
Block a user