Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1012)

Unified Diff: ui/gfx/geometry/quaternion_unittest.cc

Issue 2971903005: Fix matrix interpolation between rotations of 180 degrees (Closed)
Patch Set: forgot to revert a corresponding unit test Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/geometry/quaternion.cc ('k') | ui/gfx/transform_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/quaternion_unittest.cc
diff --git a/ui/gfx/geometry/quaternion_unittest.cc b/ui/gfx/geometry/quaternion_unittest.cc
index ef460151d37bbd1f0fe2f25234a2ced6aec97b71..38e192e1d0a669d4b9e9c1b90a0699193c33cd9b 100644
--- a/ui/gfx/geometry/quaternion_unittest.cc
+++ b/ui/gfx/geometry/quaternion_unittest.cc
@@ -142,16 +142,15 @@ TEST(QuatTest, SlerpOppositeAngles) {
Quaternion start(axis, start_radians);
Quaternion stop(axis, stop_radians);
- // When quaternions are pointed in the fully opposite direction, we take the
- // interpolated quaternion to be the first. This is arbitrary, but if we
- // change this policy, this test should fail.
- Quaternion expected = start;
-
- for (size_t i = 0; i < 100; ++i) {
- float t = static_cast<float>(i) / 100.0f;
- Quaternion interpolated = start.Slerp(stop, t);
- CompareQuaternions(expected, interpolated);
- }
+ // When quaternions are pointed in the fully opposite direction, this is
+ // ambiguous, so we rotate as per https://www.w3.org/TR/css-transforms-1/
+ Quaternion expected(axis, 0);
+
+ Quaternion interpolated = start.Slerp(stop, 0.5f);
+ EXPECT_NEAR(expected.x(), interpolated.x(), kEpsilon);
+ EXPECT_NEAR(expected.y(), interpolated.y(), kEpsilon);
+ EXPECT_NEAR(expected.z(), interpolated.z(), kEpsilon);
+ EXPECT_NEAR(expected.w(), interpolated.w(), kEpsilon);
}
} // namespace gfx
« no previous file with comments | « ui/gfx/geometry/quaternion.cc ('k') | ui/gfx/transform_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698