ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
math.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Povl Filip Sonne-Frederiksen
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#pragma once
6
7#include <numbers>
8
9namespace reusex::utils {
10
12template <typename T> constexpr inline T deg_to_rad(T degrees) {
13 return degrees * std::numbers::pi_v<T> / T(180);
14}
15
17template <typename T> constexpr inline T rad_to_deg(T radians) {
18 return radians * T(180) / std::numbers::pi_v<T>;
19}
20template <typename T>
21inline T remap(const T value, const T min_in, const T max_in,
22 const T min_out = T(0), T max_out = T(1)) {
23 return static_cast<T>(static_cast<double>(value - min_in) /
24 static_cast<double>(max_in - min_in) *
25 static_cast<double>(max_out - min_out) +
26 static_cast<double>(min_out));
27}
28} // namespace reusex::utils
T remap(const T value, const T min_in, const T max_in, const T min_out=T(0), T max_out=T(1))
Definition math.hpp:21
constexpr T rad_to_deg(T radians)
Convert radians to degrees.
Definition math.hpp:17
constexpr T deg_to_rad(T degrees)
Convert degrees to radians.
Definition math.hpp:12