OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org> | 2 Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org> |
3 2004, 2005 Rob Buis <buis@kde.org> | 3 2004, 2005 Rob Buis <buis@kde.org> |
4 2005 Eric Seidel <eric@webkit.org> | 4 2005 Eric Seidel <eric@webkit.org> |
5 | 5 |
6 This library is free software; you can redistribute it and/or | 6 This library is free software; you can redistribute it and/or |
7 modify it under the terms of the GNU Library General Public | 7 modify it under the terms of the GNU Library General Public |
8 License as published by the Free Software Foundation; either | 8 License as published by the Free Software Foundation; either |
9 version 2 of the License, or (at your option) any later version. | 9 version 2 of the License, or (at your option) any later version. |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 m_z /= tempLength; | 36 m_z /= tempLength; |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 float FloatPoint3D::angleBetween(const FloatPoint3D& y) const { | 40 float FloatPoint3D::angleBetween(const FloatPoint3D& y) const { |
41 float xLength = this->length(); | 41 float xLength = this->length(); |
42 float yLength = y.length(); | 42 float yLength = y.length(); |
43 | 43 |
44 if (xLength && yLength) { | 44 if (xLength && yLength) { |
45 float cosAngle = this->dot(y) / (xLength * yLength); | 45 float cosAngle = this->dot(y) / (xLength * yLength); |
46 // Due to round-off |cosAngle| can have a magnitude greater than 1. Clamp t
he value to [-1, | 46 // Due to round-off |cosAngle| can have a magnitude greater than 1. Clamp |
47 // 1] before computing the angle. | 47 // the value to [-1, 1] before computing the angle. |
48 return acos(clampTo(cosAngle, -1.0, 1.0)); | 48 return acos(clampTo(cosAngle, -1.0, 1.0)); |
49 } | 49 } |
50 return 0; | 50 return 0; |
51 } | 51 } |
52 | 52 |
53 String FloatPoint3D::toString() const { | 53 String FloatPoint3D::toString() const { |
54 return String::format("%lg,%lg,%lg", x(), y(), z()); | 54 return String::format("%lg,%lg,%lg", x(), y(), z()); |
55 } | 55 } |
56 | 56 |
57 } // namespace blink | 57 } // namespace blink |
OLD | NEW |