v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
angle_conversions.h
Go to the documentation of this file.
1// Copyright 2024 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Slightly adapted for inclusion in V8.
6// Copyright 2025 the V8 project authors. All rights reserved.
7
8#ifndef V8_BASE_NUMERICS_ANGLE_CONVERSIONS_H_
9#define V8_BASE_NUMERICS_ANGLE_CONVERSIONS_H_
10
11#include <concepts>
12#include <numbers>
13
14namespace v8::base {
15
16template <typename T>
17 requires std::floating_point<T>
18constexpr T DegToRad(T deg) {
19 return deg * std::numbers::pi_v<T> / 180;
20}
21
22template <typename T>
23 requires std::floating_point<T>
24constexpr T RadToDeg(T rad) {
25 return rad * 180 / std::numbers::pi_v<T>;
26}
27
28} // namespace v8::base
29
30#endif // V8_BASE_NUMERICS_ANGLE_CONVERSIONS_H_
constexpr T RadToDeg(T rad)
constexpr T DegToRad(T deg)