summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build/precompile.h2
-rw-r--r--ui/gfx/geometry/angle_conversions.h29
-rw-r--r--ui/gfx/geometry/vector3d_f.cc6
3 files changed, 32 insertions, 5 deletions
diff --git a/build/precompile.h b/build/precompile.h
index 50a9b87e2f..fd3a7fa853 100644
--- a/build/precompile.h
+++ b/build/precompile.h
@@ -11,8 +11,6 @@
#define BUILD_PRECOMPILE_H_
-#define _USE_MATH_DEFINES
-
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
diff --git a/ui/gfx/geometry/angle_conversions.h b/ui/gfx/geometry/angle_conversions.h
new file mode 100644
index 0000000000..68e9209f72
--- /dev/null
+++ b/ui/gfx/geometry/angle_conversions.h
@@ -0,0 +1,29 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_GFX_GEOMETRY_ANGLE_CONVERSIONS_H_
+#define UI_GFX_GEOMETRY_ANGLE_CONVERSIONS_H_
+
+#include "base/numerics/math_constants.h"
+#include "ui/gfx/gfx_export.h"
+
+namespace gfx {
+
+GFX_EXPORT constexpr double DegToRad(double deg) {
+ return deg * base::kPiDouble / 180.0;
+}
+GFX_EXPORT constexpr float DegToRad(float deg) {
+ return deg * base::kPiFloat / 180.0f;
+}
+
+GFX_EXPORT constexpr double RadToDeg(double rad) {
+ return rad * 180.0 / base::kPiDouble;
+}
+GFX_EXPORT constexpr float RadToDeg(float rad) {
+ return rad * 180.0f / base::kPiFloat;
+}
+
+} // namespace gfx
+
+#endif // UI_GFX_GEOMETRY_ANGLE_CONVERSIONS_H_
diff --git a/ui/gfx/geometry/vector3d_f.cc b/ui/gfx/geometry/vector3d_f.cc
index c516172eba..749e330f27 100644
--- a/ui/gfx/geometry/vector3d_f.cc
+++ b/ui/gfx/geometry/vector3d_f.cc
@@ -7,9 +7,9 @@
#include <cmath>
#include "base/strings/stringprintf.h"
+#include "ui/gfx/geometry/angle_conversions.h"
namespace {
-const float kRadiansToDegrees = 180.0f / 3.14159265f;
const double kEpsilon = 1.0e-6;
}
@@ -86,8 +86,8 @@ Vector3dF ScaleVector3d(const Vector3dF& v,
float AngleBetweenVectorsInDegrees(const gfx::Vector3dF& base,
const gfx::Vector3dF& other) {
- return acos(gfx::DotProduct(base, other) / base.Length() / other.Length()) *
- kRadiansToDegrees;
+ return gfx::RadToDeg(
+ std::acos(gfx::DotProduct(base, other) / base.Length() / other.Length()));
}
float ClockwiseAngleBetweenVectorsInDegrees(const gfx::Vector3dF& base,