// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_ALGORITHM_MATH_HPP #define NAZARA_ALGORITHM_MATH_HPP #include #include #include #include #ifndef M_PI #define M_PI 3.141592653589793238462643 #endif #ifndef M_PI_2 #define M_PI_2 1.5707963267948966192313217 #endif #ifndef M_SQRT2 #define M_SQRT2 1.4142135623730950488016887 #endif #ifndef M_SQRT3 #define M_SQRT3 1.7320508075688772935274463 #endif #ifndef M_SQRT5 #define M_SQRT5 2.23606797749979 #endif namespace Nz { template /*constexpr*/ T Approach(T value, T objective, T increment); template constexpr T Clamp(T value, T min, T max); template /*constexpr*/ std::size_t CountBits(T value); template constexpr T FromDegrees(T degrees); template constexpr T FromRadians(T radians); template constexpr T DegreeToRadian(T degrees); template /*constexpr*/ T GetNearestPowerOfTwo(T number); /*constexpr*/ unsigned int GetNumberLength(signed char number); /*constexpr*/ unsigned int GetNumberLength(unsigned char number); unsigned int GetNumberLength(int number); /*constexpr*/ unsigned int GetNumberLength(unsigned int number); unsigned int GetNumberLength(long long number); /*constexpr*/ unsigned int GetNumberLength(unsigned long long number); unsigned int GetNumberLength(float number, UInt8 precision = NAZARA_CORE_DECIMAL_DIGITS); unsigned int GetNumberLength(double number, UInt8 precision = NAZARA_CORE_DECIMAL_DIGITS); unsigned int GetNumberLength(long double number, UInt8 precision = NAZARA_CORE_DECIMAL_DIGITS); template /*constexpr*/ unsigned int IntegralLog2(T number); template /*constexpr*/ unsigned int IntegralLog2Pot(T pot); template /*constexpr*/ T IntegralPow(T base, unsigned int exponent); template constexpr T Lerp(const T& from, const T& to, const T2& interpolation); template constexpr T MultiplyAdd(T x, T y, T z); template /*constexpr*/ T NormalizeAngle(T angle); template /*constexpr*/ bool NumberEquals(T a, T b); template /*constexpr*/ bool NumberEquals(T a, T b, T maxDifference); String NumberToString(long long number, UInt8 radix = 10); template constexpr T RadianToDegree(T radians); long long StringToNumber(String str, UInt8 radix = 10, bool* ok = nullptr); template constexpr T ToDegrees(T angle); template constexpr T ToRadians(T angle); } #include #endif // NAZARA_ALGORITHM_MATH_HPP