From 9e24a7bca098751135539ecf3e80d71814ab75fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 28 Sep 2012 20:14:59 +0200 Subject: [PATCH] Don't return Matrix3 from Matrix4 member functions. Matrix3 is for 2D affine transformations, while Matrix4 is for 3D. Returning Matrix3 would allow doing this, which isn't meaningful operation at all: Matrix4 transformation; Vector2 wtf = transformation.rotationScaling().translation(); --- src/Math/Matrix3.h | 2 +- src/Math/Matrix4.h | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Math/Matrix3.h b/src/Math/Matrix3.h index f9a1f75de..8078198bc 100644 --- a/src/Math/Matrix3.h +++ b/src/Math/Matrix3.h @@ -25,7 +25,7 @@ namespace Magnum { namespace Math { /** -@brief 3x3 matrix +@brief 3x3 matrix for affine transformations in 2D @tparam T Data type Provides functions for transformations in 2D. See Matrix4 for 3D diff --git a/src/Math/Matrix4.h b/src/Math/Matrix4.h index 1d72ee70a..2563646b9 100644 --- a/src/Math/Matrix4.h +++ b/src/Math/Matrix4.h @@ -25,7 +25,7 @@ namespace Magnum { namespace Math { /** -@brief 4x4 matrix +@brief 4x4 matrix for affine transformations in 3D @tparam T Data type Provides functions for transformations in 3D. See Matrix3 for 2D @@ -138,8 +138,9 @@ template class Matrix4: public Matrix<4, T> { * @see rotation() const, rotation(T, const Vector3&), * Matrix3::rotationScaling() const */ - inline Matrix3 rotationScaling() const { - return Matrix3::from( + inline Matrix<3, T> rotationScaling() const { + /* Not Matrix3, because it is for affine 2D transformations */ + return Matrix<3, T>::from( (*this)[0].xyz(), (*this)[1].xyz(), (*this)[2].xyz()); @@ -152,8 +153,9 @@ template class Matrix4: public Matrix<4, T> { * @see rotationScaling() const, rotation(T, const Vector3&), * Matrix3::rotation() const */ - inline Matrix3 rotation() const { - return Matrix3::from( + inline Matrix<3, T> rotation() const { + /* Not Matrix3, because it is for affine 2D transformations */ + return Matrix<3, T>::from( (*this)[0].xyz().normalized(), (*this)[1].xyz().normalized(), (*this)[2].xyz().normalized()); @@ -175,8 +177,6 @@ template class Matrix4: public Matrix<4, T> { } #ifndef DOXYGEN_GENERATING_OUTPUT - inline Matrix3 ij(size_t skipRow, size_t skipCol) const { return Matrix<4, T>::ij(skipRow, skipCol); } - inline Point3D operator*(const Point3D& other) const { return Matrix<4, T>::operator*(other); }