From f137d6ba8ae4acbd2997f589646b80c387c8d0cc Mon Sep 17 00:00:00 2001 From: THoehne <77296181+THoehne@users.noreply.github.com> Date: Thu, 15 Aug 2024 14:09:38 +0200 Subject: [PATCH] Add TMatrix2. --- .../Source/Runtime/Core/public/Math/MathFwd.h | 5 + .../Core/public/Math/MathTypeConversion.hpp | 112 +++++++++--------- 2 files changed, 63 insertions(+), 54 deletions(-) diff --git a/Engine/Source/Runtime/Core/public/Math/MathFwd.h b/Engine/Source/Runtime/Core/public/Math/MathFwd.h index 41b41a3..775b673 100644 --- a/Engine/Source/Runtime/Core/public/Math/MathFwd.h +++ b/Engine/Source/Runtime/Core/public/Math/MathFwd.h @@ -86,6 +86,11 @@ namespace Phanes::Core::Math { typedef TVector4::value> Vector4Regd; typedef TVector4::value> Vector4Regf64; + // Matrix2 + + typedef TMatrix2 Matrix2; + typedef TMatrix2 Matrix2f; + typedef TMatrix2 Matrix2d; } // Phanes::Core::Math::coretypes diff --git a/Engine/Source/Runtime/Core/public/Math/MathTypeConversion.hpp b/Engine/Source/Runtime/Core/public/Math/MathTypeConversion.hpp index 39028c4..f66aca4 100644 --- a/Engine/Source/Runtime/Core/public/Math/MathTypeConversion.hpp +++ b/Engine/Source/Runtime/Core/public/Math/MathTypeConversion.hpp @@ -1,15 +1,15 @@ #pragma once // ============================================= // -// Function to convert types into each other // +// Function to convert types into each other // // // // @ref [FILE]MathUnitConversion // // ============================================= // #ifdef P_BUILD_LIB - #include "PhanesEnginePCH.h" + #include "PhanesEnginePCH.h" #else - #include + #include #endif #include "Core/public/Math/Boilerplate.h" @@ -31,77 +31,81 @@ namespace Phanes::Core::Math { - // =================================================== // - // std::to_string wrapper // - // // - // This is, to make using ToString more general // - // and allow usage of one function instead of two, // - // for converting a mathmatical type to a string. // - // =================================================== // + // =================================================== // + // std::to_string wrapper // + // // + // This is, to make using ToString more general // + // and allow usage of one function instead of two, // + // for converting a mathmatical type to a string. // + // =================================================== // - FORCEINLINE std::string ToString(long long val) { return std::to_string(val); }; + FORCEINLINE std::string ToString(long long val) { return std::to_string(val); }; - FORCEINLINE std::string ToString(double val) { return std::to_string(val); }; + FORCEINLINE std::string ToString(double val) { return std::to_string(val); }; - FORCEINLINE std::string ToString(float val) { return std::to_string(val); }; + FORCEINLINE std::string ToString(float val) { return std::to_string(val); }; - FORCEINLINE std::string ToString(int val) { return std::to_string(val); }; + FORCEINLINE std::string ToString(int val) { return std::to_string(val); }; - FORCEINLINE std::string ToString(long val) { return std::to_string(val); }; + FORCEINLINE std::string ToString(long val) { return std::to_string(val); }; - FORCEINLINE std::string ToString(long double val) { return std::to_string(val); }; + FORCEINLINE std::string ToString(long double val) { return std::to_string(val); }; - FORCEINLINE std::string ToString(unsigned long long val) { return std::to_string(val); }; + FORCEINLINE std::string ToString(unsigned long long val) { return std::to_string(val); }; - FORCEINLINE std::string ToString(unsigned int val) { return std::to_string(val); }; + FORCEINLINE std::string ToString(unsigned int val) { return std::to_string(val); }; - FORCEINLINE std::string ToString(unsigned long val) { return std::to_string(val); }; + FORCEINLINE std::string ToString(unsigned long val) { return std::to_string(val); }; - // ============ // - // ToString // - // ============ // + // ============ // + // ToString // + // ============ // - template - std::string ToString(const TVector2& v) - { - return "(" + ToString(v.x) + ", " + ToString(v.y) + ")"; - } + template + std::string ToString(const TVector2& v) + { + return "(" + ToString(v.x) + ", " + ToString(v.y) + ")"; + } - template - std::string ToString(const TIntVector2& v) - { - return "(" + ToString(v.x) + ", " + ToString(v.y) + ")"; - } + template + std::string ToString(const TIntVector2& v) + { + return "(" + ToString(v.x) + ", " + ToString(v.y) + ")"; + } - template - std::string ToString(const TVector3& v) - { - return "(" + ToString(v.x) + ", " + ToString(v.y) + ", " + ToString(v.z) + ")"; - } + template + std::string ToString(const TVector3& v) + { + return "(" + ToString(v.x) + ", " + ToString(v.y) + ", " + ToString(v.z) + ")"; + } - template - std::string ToString(const TIntVector3& v) - { - return "(" + ToString(v.x) + ", " + ToString(v.y) + ", " + ToString(v.z) + ")"; - } + template + std::string ToString(const TIntVector3& v) + { + return "(" + ToString(v.x) + ", " + ToString(v.y) + ", " + ToString(v.z) + ")"; + } - template - std::string ToString(const TVector4& v) - { - return "(" + ToString(v.x) + ", " + ToString(v.y) + ", " + ToString(v.z) + ", " + ToString(v.w) + ")"; - } + template + std::string ToString(const TVector4& v) + { + return "(" + ToString(v.x) + ", " + ToString(v.y) + ", " + ToString(v.z) + ", " + ToString(v.w) + ")"; + } - template - std::string ToString(const TIntVector4& v) - { - return "(" + ToString(v.x) + ", " + ToString(v.y) + ", " + ToString(v.z) + ", " + ToString(v.w) + ")"; - } + template + std::string ToString(const TIntVector4& v) + { + return "(" + ToString(v.x) + ", " + ToString(v.y) + ", " + ToString(v.z) + ", " + ToString(v.w) + ")"; + } - //std::string toString(const Vector4& v); + template + std::string ToString(const TMatrix2& m) + { + return "([" + ToString(m(0, 0)) + ", " + ToString(m(0, 1)) + "], [" + ToString(m(1, 0)) + ", " + ToString(m(1, 1)) + "])"; + } - //std::string toString(const Matrix3& v); + //std::string toString(const Matrix3& v); }