| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) | 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 * | 19 * |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 #include "config.h" | 22 #include "config.h" |
| 23 #include "platform/transforms/RotateTransformOperation.h" | 23 #include "platform/transforms/RotateTransformOperation.h" |
| 24 | 24 |
| 25 #include "platform/animation/AnimationUtilities.h" | 25 #include "platform/animation/AnimationUtilities.h" |
| 26 #include "platform/geometry/FloatPoint3D.h" | 26 #include "platform/geometry/FloatPoint3D.h" |
| 27 #include "wtf/MathExtras.h" | 27 #include "wtf/MathExtras.h" |
| 28 #include <algorithm> | 28 #include <algorithm> |
| 29 | 29 |
| 30 using namespace std; | |
| 31 | |
| 32 namespace blink { | 30 namespace blink { |
| 33 | 31 |
| 34 static const double angleEpsilon = 1e-4; | 32 static const double angleEpsilon = 1e-4; |
| 35 | 33 |
| 36 FloatPoint3D RotateTransformOperation::axis() const | 34 FloatPoint3D RotateTransformOperation::axis() const |
| 37 { | 35 { |
| 38 return FloatPoint3D(x(), y(), z()); | 36 return FloatPoint3D(x(), y(), z()); |
| 39 } | 37 } |
| 40 | 38 |
| 41 bool RotateTransformOperation::shareSameAxis(const RotateTransformOperation* fro
m, const RotateTransformOperation* to, FloatPoint3D* axis, double* fromAngle, do
uble* toAngle) | 39 bool RotateTransformOperation::shareSameAxis(const RotateTransformOperation* fro
m, const RotateTransformOperation* to, FloatPoint3D* axis, double* fromAngle, do
uble* toAngle) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 toT.blend(fromT, progress); | 126 toT.blend(fromT, progress); |
| 129 | 127 |
| 130 // Extract the result as a quaternion | 128 // Extract the result as a quaternion |
| 131 TransformationMatrix::DecomposedType decomp; | 129 TransformationMatrix::DecomposedType decomp; |
| 132 toT.decompose(decomp); | 130 toT.decompose(decomp); |
| 133 | 131 |
| 134 // Convert that to Axis/Angle form | 132 // Convert that to Axis/Angle form |
| 135 double x = -decomp.quaternionX; | 133 double x = -decomp.quaternionX; |
| 136 double y = -decomp.quaternionY; | 134 double y = -decomp.quaternionY; |
| 137 double z = -decomp.quaternionZ; | 135 double z = -decomp.quaternionZ; |
| 138 double length = sqrt(x * x + y * y + z * z); | 136 double length = std::sqrt(x * x + y * y + z * z); |
| 139 double angle = 0; | 137 double angle = 0; |
| 140 | 138 |
| 141 if (length > 0.00001) { | 139 if (length > 0.00001) { |
| 142 x /= length; | 140 x /= length; |
| 143 y /= length; | 141 y /= length; |
| 144 z /= length; | 142 z /= length; |
| 145 angle = rad2deg(acos(decomp.quaternionW) * 2); | 143 angle = rad2deg(std::acos(decomp.quaternionW) * 2); |
| 146 } else { | 144 } else { |
| 147 x = 0; | 145 x = 0; |
| 148 y = 0; | 146 y = 0; |
| 149 z = 1; | 147 z = 1; |
| 150 } | 148 } |
| 151 return RotateTransformOperation::create(x, y, z, angle, Rotate3D); | 149 return RotateTransformOperation::create(x, y, z, angle, Rotate3D); |
| 152 } | 150 } |
| 153 | 151 |
| 154 bool RotateTransformOperation::canBlendWith(const TransformOperation& other) con
st | 152 bool RotateTransformOperation::canBlendWith(const TransformOperation& other) con
st |
| 155 { | 153 { |
| 156 return other.isSameType(*this); | 154 return other.isSameType(*this); |
| 157 } | 155 } |
| 158 | 156 |
| 159 } // namespace blink | 157 } // namespace blink |
| OLD | NEW |