From c86ec0ae82a70e57e95e9267c91f987504624582 Mon Sep 17 00:00:00 2001 From: peri4 Date: Mon, 14 Aug 2023 12:37:32 +0300 Subject: [PATCH] normalizeAngleDeg methods --- libs/main/math/pimathbase.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/libs/main/math/pimathbase.h b/libs/main/math/pimathbase.h index 6d5b9169..02ba01a3 100644 --- a/libs/main/math/pimathbase.h +++ b/libs/main/math/pimathbase.h @@ -157,6 +157,34 @@ inline PIVector piAbs(const PIVector & v) { } +template +void normalizeAngleDeg360(T & a) { + while (a < 0.) + a += 360.; + while (a > 360.) + a -= 360.; +} +template +double normalizedAngleDeg360(T a) { + normalizeAngleDeg360(a); + return a; +} + + +template +void normalizeAngleDeg180(T & a) { + while (a < -180.) + a += 360.; + while (a > 180.) + a -= 360.; +} +template +double normalizedAngleDeg180(T a) { + normalizeAngleDeg180(a); + return a; +} + + template bool OLS_Linear(const PIVector> & input, T * out_a, T * out_b) { static_assert(std::is_arithmetic::value, "Type must be arithmetic");