mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Fix looking at with 180 degree arc
Co-authored-by: Fruitsalad <949631+fruitsalad@users.noreply.github.com>
This commit is contained in:
@@ -235,6 +235,36 @@ TEST_CASE("[Quaternion] Construct Basis Axes") {
|
||||
CHECK(q[3] == doctest::Approx(0.8582598));
|
||||
}
|
||||
|
||||
TEST_CASE("[Quaternion] Construct Shortest Arc For 180 Degree Arc") {
|
||||
Vector3 up(0, 1, 0);
|
||||
Vector3 down(0, -1, 0);
|
||||
Vector3 left(-1, 0, 0);
|
||||
Vector3 right(1, 0, 0);
|
||||
Vector3 forward(0, 0, -1);
|
||||
Vector3 back(0, 0, 1);
|
||||
|
||||
// When we have a 180 degree rotation quaternion which was defined as
|
||||
// A to B, logically when we transform A we expect to get B.
|
||||
Quaternion left_to_right(left, right);
|
||||
Quaternion right_to_left(right, left);
|
||||
CHECK(left_to_right.xform(left).is_equal_approx(right));
|
||||
CHECK(Quaternion(right, left).xform(right).is_equal_approx(left));
|
||||
CHECK(Quaternion(up, down).xform(up).is_equal_approx(down));
|
||||
CHECK(Quaternion(down, up).xform(down).is_equal_approx(up));
|
||||
CHECK(Quaternion(forward, back).xform(forward).is_equal_approx(back));
|
||||
CHECK(Quaternion(back, forward).xform(back).is_equal_approx(forward));
|
||||
|
||||
// With (arbitrary) opposite vectors that are not axis-aligned as parameters.
|
||||
Vector3 diagonal_up = Vector3(1.2, 2.3, 4.5).normalized();
|
||||
Vector3 diagonal_down = -diagonal_up;
|
||||
Quaternion q1(diagonal_up, diagonal_down);
|
||||
CHECK(q1.xform(diagonal_down).is_equal_approx(diagonal_up));
|
||||
CHECK(q1.xform(diagonal_up).is_equal_approx(diagonal_down));
|
||||
|
||||
// For the consistency of the rotation direction, they should be symmetrical to the plane.
|
||||
CHECK(left_to_right.is_equal_approx(right_to_left.inverse()));
|
||||
}
|
||||
|
||||
TEST_CASE("[Quaternion] Get Euler Orders") {
|
||||
double x = Math::deg_to_rad(30.0);
|
||||
double y = Math::deg_to_rad(45.0);
|
||||
|
||||
Reference in New Issue
Block a user