Add TMatrix2.

This commit is contained in:
THoehne 2024-08-15 14:09:38 +02:00
parent 2bbeff1e23
commit f137d6ba8a
2 changed files with 63 additions and 54 deletions

View File

@ -86,6 +86,11 @@ namespace Phanes::Core::Math {
typedef TVector4<double, SIMD::use_simd<double, 4, true>::value> Vector4Regd;
typedef TVector4<double, SIMD::use_simd<double, 4, true>::value> Vector4Regf64;
// Matrix2
typedef TMatrix2<float> Matrix2;
typedef TMatrix2<float> Matrix2f;
typedef TMatrix2<double> Matrix2d;
} // Phanes::Core::Math::coretypes

View File

@ -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 <string>
#include <string>
#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<RealType T, bool S>
std::string ToString(const TVector2<T, S>& v)
{
return "(" + ToString(v.x) + ", " + ToString(v.y) + ")";
}
template<RealType T, bool S>
std::string ToString(const TVector2<T, S>& v)
{
return "(" + ToString(v.x) + ", " + ToString(v.y) + ")";
}
template<IntType T, bool S>
std::string ToString(const TIntVector2<T, S>& v)
{
return "(" + ToString(v.x) + ", " + ToString(v.y) + ")";
}
template<IntType T, bool S>
std::string ToString(const TIntVector2<T, S>& v)
{
return "(" + ToString(v.x) + ", " + ToString(v.y) + ")";
}
template<RealType T, bool S>
std::string ToString(const TVector3<T, S>& v)
{
return "(" + ToString(v.x) + ", " + ToString(v.y) + ", " + ToString(v.z) + ")";
}
template<RealType T, bool S>
std::string ToString(const TVector3<T, S>& v)
{
return "(" + ToString(v.x) + ", " + ToString(v.y) + ", " + ToString(v.z) + ")";
}
template<IntType T, bool S>
std::string ToString(const TIntVector3<T, S>& v)
{
return "(" + ToString(v.x) + ", " + ToString(v.y) + ", " + ToString(v.z) + ")";
}
template<IntType T, bool S>
std::string ToString(const TIntVector3<T, S>& v)
{
return "(" + ToString(v.x) + ", " + ToString(v.y) + ", " + ToString(v.z) + ")";
}
template<RealType T, bool S>
std::string ToString(const TVector4<T, S>& v)
{
return "(" + ToString(v.x) + ", " + ToString(v.y) + ", " + ToString(v.z) + ", " + ToString(v.w) + ")";
}
template<RealType T, bool S>
std::string ToString(const TVector4<T, S>& v)
{
return "(" + ToString(v.x) + ", " + ToString(v.y) + ", " + ToString(v.z) + ", " + ToString(v.w) + ")";
}
template<IntType T, bool S>
std::string ToString(const TIntVector4<T, S>& v)
{
return "(" + ToString(v.x) + ", " + ToString(v.y) + ", " + ToString(v.z) + ", " + ToString(v.w) + ")";
}
template<IntType T, bool S>
std::string ToString(const TIntVector4<T, S>& v)
{
return "(" + ToString(v.x) + ", " + ToString(v.y) + ", " + ToString(v.z) + ", " + ToString(v.w) + ")";
}
//std::string toString(const Vector4& v);
template<RealType T>
std::string ToString(const TMatrix2<T>& 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);
}