From a2fcbc94fd38a2703a75fbb6310a3827f97c09d5 Mon Sep 17 00:00:00 2001 From: Jeffery Myers Date: Mon, 21 Oct 2024 09:38:42 -0700 Subject: [PATCH] [Raymath] Add matrix operators to raymath for C++ (#4409) * Add matrix operators to raymath for C++ * Fix spaces --- src/raymath.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/raymath.h b/src/raymath.h index 71b17cc2..d1b5ab01 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -2895,6 +2895,40 @@ inline const Quaternion& operator *= (Quaternion& lhs, const Matrix& rhs) lhs = QuaternionTransform(lhs, rhs); return lhs; } + +// Matrix operators +inline Matrix operator + (const Matrix& lhs, const Matrix& rhs) +{ + return MatrixAdd(lhs, rhs); +} + +inline const Matrix& operator += (Matrix& lhs, const Matrix& rhs) +{ + lhs = MatrixAdd(lhs, rhs); + return lhs; +} + +inline Matrix operator - (const Matrix& lhs, const Matrix& rhs) +{ + return MatrixSubtract(lhs, rhs); +} + +inline const Matrix& operator -= (Matrix& lhs, const Matrix& rhs) +{ + lhs = MatrixSubtract(lhs, rhs); + return lhs; +} + +inline Matrix operator * (const Matrix& lhs, const Matrix& rhs) +{ + return MatrixMultiply(lhs, rhs); +} + +inline const Matrix& operator *= (Matrix& lhs, const Matrix& rhs) +{ + lhs = MatrixMultiply(lhs, rhs); + return lhs; +} //------------------------------------------------------------------------------- #endif // C++ operators