Improve math module (#396)

* Improve math module

- Mark almost everything constexpr
- Equality (a == b) is now exact, down to the bit level. If you want approximate equality use the new ApproxEqual method/static method
- Rename Nz::Extend to Nz::Extent
- Removed Make[] and Set[] methods in favor of their static counterpart and operator=
This commit is contained in:
Jérôme Leclercq
2023-06-02 22:30:51 +02:00
committed by GitHub
parent de88873c35
commit 1a55b550fb
64 changed files with 2200 additions and 3758 deletions

View File

@@ -34,18 +34,16 @@ namespace Nz
constexpr Angle(Angle&&) noexcept = default;
~Angle() = default;
constexpr bool ApproxEqual(const Angle& angle) const;
constexpr bool ApproxEqual(const Angle& angle, T maxDifference) const;
T GetCos() const;
T GetSin() const;
std::pair<T, T> GetSinCos() const;
T GetTan() const;
constexpr Angle& MakeZero();
constexpr Angle& Normalize();
constexpr Angle& Set(Angle ang);
template<typename U> constexpr Angle& Set(const Angle<Unit, U>& ang);
template<AngleUnit ToUnit> T To() const;
template<AngleUnit ToUnit> Angle<ToUnit, T> ToAngle() const;
constexpr T ToDegrees() const;
@@ -76,7 +74,13 @@ namespace Nz
constexpr bool operator==(Angle other) const;
constexpr bool operator!=(Angle other) const;
constexpr bool operator<(Angle other) const;
constexpr bool operator<=(Angle other) const;
constexpr bool operator>(Angle other) const;
constexpr bool operator>=(Angle other) const;
static constexpr bool ApproxEqual(const Angle& lhs, const Angle& rhs);
static constexpr bool ApproxEqual(const Angle& lhs, const Angle& rhs, T maxDifference);
template<AngleUnit FromUnit> static constexpr Angle From(T value);
static constexpr Angle FromDegrees(T degrees);
static constexpr Angle FromRadians(T radians);