From f60bd0e3e43bc9c74247e2599580d9356d778647 Mon Sep 17 00:00:00 2001 From: Redstone1024 <2824517378@qq.com> Date: Sun, 24 Nov 2024 22:39:45 +0800 Subject: [PATCH] feat(numerics): add the mathematical constant tool --- .../Source/Public/Numerics/Numbers.h | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Redcraft.Utility/Source/Public/Numerics/Numbers.h diff --git a/Redcraft.Utility/Source/Public/Numerics/Numbers.h b/Redcraft.Utility/Source/Public/Numerics/Numbers.h new file mode 100644 index 0000000..10d3459 --- /dev/null +++ b/Redcraft.Utility/Source/Public/Numerics/Numbers.h @@ -0,0 +1,40 @@ +#pragma once + +#include "CoreTypes.h" +#include "TypeTraits/TypeTraits.h" + +NAMESPACE_REDCRAFT_BEGIN +NAMESPACE_MODULE_BEGIN(Redcraft) +NAMESPACE_MODULE_BEGIN(Utility) + +NAMESPACE_BEGIN(Math) + +template +struct TConstant +{ + static constexpr T E = static_cast(2.71828182845904523536028747135266249775724709369995); + static constexpr T Log2E = static_cast(1.44269504088896340735992468100189213742664595415299); + static constexpr T Log10E = static_cast(0.43429448190325182765112891891660508229439700580367); + static constexpr T Pi = static_cast(3.14159265358979323846264338327950288419716939937511); + static constexpr T HalfPi = static_cast(1.57079632679489661923132169163975144209858469968756); + static constexpr T TwoPi = static_cast(6.28318530717958647692528676655900576839433879875022); + static constexpr T SquaredPi = static_cast(9.86960440108935861883449099987615113531369940724079); + static constexpr T InvPi = static_cast(0.31830988618379067153776752674502872406891929148091); + static constexpr T InvSqrtPi = static_cast(0.56418958354775628694807945156077258584405062932900); + static constexpr T Ln2 = static_cast(0.69314718055994530941723212145817656807550013436026); + static constexpr T Ln10 = static_cast(2.30258509299404568401799145468436420760110148862877); + static constexpr T Sqrt2 = static_cast(1.41421356237309504880168872420969807856967187537694); + static constexpr T Sqrt3 = static_cast(1.73205080756887729352744634150587236694280525381038); + static constexpr T InvSqrt2 = static_cast(0.70710678118654752440084436210484903928483593768847); + static constexpr T InvSqrt3 = static_cast(0.57735026918962576450914878050195745564760175127013); + static constexpr T HalfSqrt2 = static_cast(0.70710678118654752440084436210484903928483593768847); + static constexpr T HalfSqrt3 = static_cast(0.86602540378443864676372317075293618347140262690519); + static constexpr T EGamma = static_cast(0.57721566490153286060651209008240243104215933593992); + static constexpr T GoldenRatio = static_cast(1.61803398874989484820458683436563811772030917980576); +}; + +NAMESPACE_END(Math) + +NAMESPACE_MODULE_END(Utility) +NAMESPACE_MODULE_END(Redcraft) +NAMESPACE_REDCRAFT_END