diff --git a/include/mitsuba/core/matrix.h b/include/mitsuba/core/matrix.h index 4b97da81..c542dbad 100644 --- a/include/mitsuba/core/matrix.h +++ b/include/mitsuba/core/matrix.h @@ -412,6 +412,15 @@ public: target.m[1][0] = -m[1][0] * invDet; return true; } + + /// Matrix-vector multiplication + inline Vector2 operator*(const Vector2 &v) const { + return Vector2( + m[0][0] * v.x + m[0][1] * v.y, + m[1][0] * v.x + m[1][1] * v.y + ); + } + }; /** @@ -448,6 +457,14 @@ public: - (m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])) + (m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]))); } + + /// Matrix-vector multiplication + inline Vector operator*(const Vector &v) const { + return Vector( + m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z, + m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z, + m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z); + } }; @@ -487,6 +504,16 @@ struct MTS_EXPORT_CORE Matrix4x4 : public Matrix<4, 4, Float> { - (m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])) + (m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]))); } + + /// Matrix-vector multiplication + inline Vector4 operator*(const Vector4 &v) const { + return Vector4( + m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3] * v.w, + m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z + m[1][3] * v.w, + m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z + m[2][3] * v.w, + m[3][0] * v.x + m[3][1] * v.y + m[3][2] * v.z + m[3][3] * v.w + ); + } }; MTS_NAMESPACE_END