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, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 resultAngleB = b.angle; | 75 resultAngleB = b.angle; |
76 return true; | 76 return true; |
77 } | 77 } |
78 | 78 |
79 if (isZeroB) { | 79 if (isZeroB) { |
80 resultAxis = a.axis; | 80 resultAxis = a.axis; |
81 resultAngleA = a.angle; | 81 resultAngleA = a.angle; |
82 return true; | 82 return true; |
83 } | 83 } |
84 | 84 |
| 85 double dot = a.axis.dot(b.axis); |
| 86 if (dot < 0) |
| 87 return false; |
| 88 |
85 double aSquared = a.axis.lengthSquared(); | 89 double aSquared = a.axis.lengthSquared(); |
86 double bSquared = b.axis.lengthSquared(); | 90 double bSquared = b.axis.lengthSquared(); |
87 double dot = a.axis.dot(b.axis); | |
88 double error = std::abs(1 - (dot * dot) / (aSquared * bSquared)); | 91 double error = std::abs(1 - (dot * dot) / (aSquared * bSquared)); |
89 if (error > kAngleEpsilon) | 92 if (error > kAngleEpsilon) |
90 return false; | 93 return false; |
91 | 94 |
92 resultAxis = a.axis; | 95 resultAxis = a.axis; |
93 resultAngleA = a.angle; | 96 resultAngleA = a.angle; |
94 resultAngleB = b.angle; | 97 resultAngleB = b.angle; |
95 return true; | 98 return true; |
96 } | 99 } |
97 | 100 |
(...skipping 21 matching lines...) Expand all Loading... |
119 if (getCommonAxis(a, b, axis, angleA, angleB)) | 122 if (getCommonAxis(a, b, axis, angleA, angleB)) |
120 return Rotation(axis, angleA + angleB); | 123 return Rotation(axis, angleA + angleB); |
121 | 124 |
122 TransformationMatrix matrix; | 125 TransformationMatrix matrix; |
123 matrix.rotate3d(a); | 126 matrix.rotate3d(a); |
124 matrix.rotate3d(b); | 127 matrix.rotate3d(b); |
125 return extractFromMatrix(matrix, b); | 128 return extractFromMatrix(matrix, b); |
126 } | 129 } |
127 | 130 |
128 } // namespace blink | 131 } // namespace blink |
OLD | NEW |