From 12bf687f339ae85917fa6862d2ebfd6cec25f8cb Mon Sep 17 00:00:00 2001 From: josh Date: Thu, 1 Feb 2024 20:22:32 -0500 Subject: [PATCH] Implement static operator* --- include/J3ML/LinearAlgebra/Matrix4x4.h | 2 -- include/J3ML/LinearAlgebra/Vector2.h | 11 +++++++++++ src/J3ML/LinearAlgebra/Matrix4x4.cpp | 7 ------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/J3ML/LinearAlgebra/Matrix4x4.h b/include/J3ML/LinearAlgebra/Matrix4x4.h index 433557d..54d213d 100644 --- a/include/J3ML/LinearAlgebra/Matrix4x4.h +++ b/include/J3ML/LinearAlgebra/Matrix4x4.h @@ -95,8 +95,6 @@ namespace LinearAlgebra { @see RotateFromTo(). */ static Matrix4x4 LookAt(const Vector3& localFwd, const Vector3& targetDir, const Vector3& localUp, const Vector3& worldUp); - static Matrix4x4 FromTranslation(const Vector3& translation); - /// Returns the translation part. /** The translation part is stored in the fourth column of this matrix. This is equivalent to decomposing this matrix in the form M = T * M', i.e. this translation is applied last, diff --git a/include/J3ML/LinearAlgebra/Vector2.h b/include/J3ML/LinearAlgebra/Vector2.h index 438a186..9552b96 100644 --- a/include/J3ML/LinearAlgebra/Vector2.h +++ b/include/J3ML/LinearAlgebra/Vector2.h @@ -7,6 +7,8 @@ namespace LinearAlgebra { using namespace J3ML; + + /// A 2D (x, y) ordered pair. class Vector2 { public: @@ -121,6 +123,10 @@ namespace LinearAlgebra { /// Multiplies this vector by a vector, element-wise /// @note Mathematically, the multiplication of two vectors is not defined in linear space structures, /// but this function is provided here for syntactical convenience. + Vector2 operator *(const Vector2& rhs) const + { + + } Vector2 Mul(const Vector2& v) const; /// Divides this vector by a scalar. @@ -147,4 +153,9 @@ namespace LinearAlgebra { float y = 0; }; + + static Vector2 operator*(float lhs, const Vector2 &rhs) + { + return rhs * lhs; + } } \ No newline at end of file diff --git a/src/J3ML/LinearAlgebra/Matrix4x4.cpp b/src/J3ML/LinearAlgebra/Matrix4x4.cpp index bd74f8d..fae41b5 100644 --- a/src/J3ML/LinearAlgebra/Matrix4x4.cpp +++ b/src/J3ML/LinearAlgebra/Matrix4x4.cpp @@ -514,11 +514,4 @@ namespace LinearAlgebra { At(row, 2) *= scalar; At(row, 3) *= scalar; } - - Matrix4x4 Matrix4x4::FromTranslation(const Vector3 &translation) { - Matrix4x4 m; - m.SetTranslatePart(translation); - m.Set3x3Part(Matrix3x3::Identity); - return m; - } } \ No newline at end of file