Math/Angle: Fix Normalization range ([0;360] => [-180;180])
This commit is contained in:
parent
496800fc5c
commit
6dc27e7948
|
|
@ -2,6 +2,7 @@
|
|||
// This file is part of the "Nazara Engine - Math module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <NazaraUtils/Algorithm.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
|
|
@ -285,11 +286,13 @@ namespace Nz
|
|||
constexpr Angle<Unit, T>& Angle<Unit, T>::Normalize()
|
||||
{
|
||||
constexpr T limit = Detail::AngleUtils<Unit>::template GetLimit<T>();
|
||||
constexpr T halfLimit = limit / T(2);
|
||||
|
||||
value = std::fmod(value, limit);
|
||||
value = Nz::Mod(value + halfLimit, limit);
|
||||
if (value < T(0))
|
||||
value += limit;
|
||||
|
||||
value -= halfLimit;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue