| Index: ui/gfx/geometry/vector3d_f.cc
|
| diff --git a/ui/gfx/geometry/vector3d_f.cc b/ui/gfx/geometry/vector3d_f.cc
|
| index a30f9db5cbe35cc7fe0c9224dadbca5baf9736df..87223880669ed51a4bd15cc1302d31a14d16a4fa 100644
|
| --- a/ui/gfx/geometry/vector3d_f.cc
|
| +++ b/ui/gfx/geometry/vector3d_f.cc
|
| @@ -8,6 +8,10 @@
|
|
|
| #include "base/strings/stringprintf.h"
|
|
|
| +namespace {
|
| +const float kRadiansToDegrees = 180.0f / 3.14159265f;
|
| +}
|
| +
|
| namespace gfx {
|
|
|
| Vector3dF::Vector3dF()
|
| @@ -85,4 +89,25 @@ Vector3dF ScaleVector3d(const Vector3dF& v,
|
| return scaled_v;
|
| }
|
|
|
| +float AngleBetweenVectorsInDegrees(const gfx::Vector3dF& base,
|
| + const gfx::Vector3dF& other) {
|
| + return acos(gfx::DotProduct(base, other) / base.Length() / other.Length()) *
|
| + kRadiansToDegrees;
|
| +}
|
| +
|
| +float ClockwiseAngleBetweenVectorsInDegrees(const gfx::Vector3dF& base,
|
| + const gfx::Vector3dF& other,
|
| + const gfx::Vector3dF& normal) {
|
| + float angle = AngleBetweenVectorsInDegrees(base, other);
|
| + gfx::Vector3dF cross(base);
|
| + cross.Cross(other);
|
| +
|
| + // If the dot product of this cross product is normal, it means that the
|
| + // shortest angle between |base| and |other| was counterclockwise with respect
|
| + // to the surface represented by |normal| and this angle must be reversed.
|
| + if (gfx::DotProduct(cross, normal) > 0.0f)
|
| + angle = 360.0f - angle;
|
| + return angle;
|
| +}
|
| +
|
| } // namespace gfx
|
|
|