angle_conversions.h 821 B

1234567891011121314151617181920212223242526272829
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_GFX_GEOMETRY_ANGLE_CONVERSIONS_H_
  5. #define UI_GFX_GEOMETRY_ANGLE_CONVERSIONS_H_
  6. #include "base/numerics/math_constants.h"
  7. #include "ui/gfx/geometry/geometry_export.h"
  8. namespace gfx {
  9. GEOMETRY_EXPORT constexpr double DegToRad(double deg) {
  10. return deg * base::kPiDouble / 180.0;
  11. }
  12. GEOMETRY_EXPORT constexpr float DegToRad(float deg) {
  13. return deg * base::kPiFloat / 180.0f;
  14. }
  15. GEOMETRY_EXPORT constexpr double RadToDeg(double rad) {
  16. return rad * 180.0 / base::kPiDouble;
  17. }
  18. GEOMETRY_EXPORT constexpr float RadToDeg(float rad) {
  19. return rad * 180.0f / base::kPiFloat;
  20. }
  21. } // namespace gfx
  22. #endif // UI_GFX_GEOMETRY_ANGLE_CONVERSIONS_H_