| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef Rotation_h | 5 #ifndef Rotation_h |
| 6 #define Rotation_h | 6 #define Rotation_h |
| 7 | 7 |
| 8 #include "platform/geometry/FloatPoint3D.h" | 8 #include "platform/geometry/FloatPoint3D.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 struct PLATFORM_EXPORT Rotation { | 12 struct PLATFORM_EXPORT Rotation { |
| 13 Rotation() : axis(0, 0, 0), angle(0) {} | 13 Rotation() : axis(0, 0, 0), angle(0) {} |
| 14 | 14 |
| 15 Rotation(const FloatPoint3D& axis, double angle) : axis(axis), angle(angle) {} | 15 Rotation(const FloatPoint3D& axis, double angle) : axis(axis), angle(angle) {} |
| 16 | 16 |
| 17 // If either rotation is effectively "zero" or both rotations share the same n
ormalized axes this function returns true | 17 // If either rotation is effectively "zero" or both rotations share the same |
| 18 // and the "non-zero" axis is returned as resultAxis and the effective angles
are returned as resultAngleA and resultAngleB. | 18 // normalized axes this function returns true and the "non-zero" axis is |
| 19 // Otherwise false is returned. | 19 // returned as resultAxis and the effective angles are returned as |
| 20 // resultAngleA and resultAngleB. Otherwise false is returned. |
| 20 static bool getCommonAxis(const Rotation& /*a*/, | 21 static bool getCommonAxis(const Rotation& /*a*/, |
| 21 const Rotation& /*b*/, | 22 const Rotation& /*b*/, |
| 22 FloatPoint3D& resultAxis, | 23 FloatPoint3D& resultAxis, |
| 23 double& resultAngleA, | 24 double& resultAngleA, |
| 24 double& resultAngleB); | 25 double& resultAngleB); |
| 25 | 26 |
| 26 // A progress of 0 corresponds to "from" and a progress of 1 corresponds to "t
o". | 27 // A progress of 0 corresponds to "from" and a progress of 1 corresponds to |
| 28 // "to". |
| 27 static Rotation slerp(const Rotation& from, | 29 static Rotation slerp(const Rotation& from, |
| 28 const Rotation& to, | 30 const Rotation& to, |
| 29 double progress); | 31 double progress); |
| 30 | 32 |
| 31 // Returns a rotation whose effect is equivalent to applying a followed by b. | 33 // Returns a rotation whose effect is equivalent to applying a followed by b. |
| 32 static Rotation add(const Rotation& /*a*/, const Rotation& /*b*/); | 34 static Rotation add(const Rotation& /*a*/, const Rotation& /*b*/); |
| 33 | 35 |
| 34 // No restrictions on the axis vector. | 36 // No restrictions on the axis vector. |
| 35 FloatPoint3D axis; | 37 FloatPoint3D axis; |
| 36 | 38 |
| 37 // Measured in degrees. | 39 // Measured in degrees. |
| 38 double angle; | 40 double angle; |
| 39 }; | 41 }; |
| 40 | 42 |
| 41 } // namespace blink | 43 } // namespace blink |
| 42 | 44 |
| 43 #endif // Rotation_h | 45 #endif // Rotation_h |
| OLD | NEW |