// Copyright (C) 2020 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 #include namespace Nz { template constexpr T HalfPi = T(1.5707963267948966192313216916398); template constexpr T Pi = T(3.1415926535897932384626433832795); template constexpr T Sqrt2 = T(1.4142135623730950488016887242097); template constexpr T Sqrt3 = T(1.7320508075688772935274463415059); template constexpr T Sqrt5 = T(2.2360679774997896964091736687313); template class Angle; template constexpr T Approach(T value, T objective, T increment); template constexpr T Clamp(T value, T min, T max); template constexpr Angle Clamp(Angle value, T min, T max); template T ClearBit(T number, T bit); template constexpr std::size_t CountBits(T value); 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 bool NumberEquals(T a, T b); template constexpr bool NumberEquals(T a, T b, T maxDifference); inline std::string NumberToString(long long number, UInt8 radix = 10); template constexpr T RadianToDegree(T radians); template T SetBit(T number, T bit); inline long long StringToNumber(const std::string_view& str, UInt8 radix = 10, bool* ok = nullptr); template bool TestBit(T number, T bit); template T ToggleBit(T number, T bit); } #include #endif // NAZARA_ALGORITHM_MATH_HPP