From 14460cf0f4dde064f520bbae759dd15362bbab7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 27 Feb 2013 12:01:23 +0100 Subject: [PATCH] Math: renamed *::matrix() to ::toMatrix(). It better visualizes the fact that neither (Dual)Complex nor (Dual)Quaternion contains the matrix inside them, but performs (possibly costly) conversion. --- src/Math/Complex.h | 4 ++-- src/Math/DualComplex.h | 6 +++--- src/Math/DualQuaternion.h | 6 +++--- src/Math/Quaternion.h | 4 ++-- src/Math/Test/ComplexTest.cpp | 2 +- src/Math/Test/DualComplexTest.cpp | 2 +- src/Math/Test/DualQuaternionTest.cpp | 4 ++-- src/Math/Test/QuaternionTest.cpp | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Math/Complex.h b/src/Math/Complex.h index b88d8e4d0..8bd7486ac 100644 --- a/src/Math/Complex.h +++ b/src/Math/Complex.h @@ -155,9 +155,9 @@ template class Complex { * b & a * \end{pmatrix} * @f] - * @see DualComplex::matrix(), Matrix3::from(const Matrix<2, T>&, const Vector2&) + * @see DualComplex::toMatrix(), Matrix3::from(const Matrix<2, T>&, const Vector2&) */ - Matrix<2, T> matrix() const { + Matrix<2, T> toMatrix() const { return {Vector<2, T>(_real, _imaginary), Vector<2, T>(-_imaginary, _real)}; } diff --git a/src/Math/DualComplex.h b/src/Math/DualComplex.h index b96bbce88..a17198d8d 100644 --- a/src/Math/DualComplex.h +++ b/src/Math/DualComplex.h @@ -130,10 +130,10 @@ template class DualComplex: public Dual> { /** * @brief Convert dual complex number to transformation matrix * - * @see Complex::matrix() + * @see Complex::toMatrix() */ - inline Matrix3 matrix() const { - return Matrix3::from(this->real().matrix(), translation()); + inline Matrix3 toMatrix() const { + return Matrix3::from(this->real().toMatrix(), translation()); } /** diff --git a/src/Math/DualQuaternion.h b/src/Math/DualQuaternion.h index 9e10be0aa..6a305e0b5 100644 --- a/src/Math/DualQuaternion.h +++ b/src/Math/DualQuaternion.h @@ -146,10 +146,10 @@ template class DualQuaternion: public Dual> { /** * @brief Convert dual quaternion to transformation matrix * - * @see Quaternion::matrix() + * @see Quaternion::toMatrix() */ - Matrix4 matrix() const { - return Matrix4::from(this->real().matrix(), translation()); + Matrix4 toMatrix() const { + return Matrix4::from(this->real().toMatrix(), translation()); } /** diff --git a/src/Math/Quaternion.h b/src/Math/Quaternion.h index 5eef4346f..e92397145 100644 --- a/src/Math/Quaternion.h +++ b/src/Math/Quaternion.h @@ -204,9 +204,9 @@ template class Quaternion { /** * @brief Convert quaternion to rotation matrix * - * @see DualQuaternion::matrix(), Matrix4::from(const Matrix<3, T>&, const Vector3&) + * @see DualQuaternion::toMatrix(), Matrix4::from(const Matrix<3, T>&, const Vector3&) */ - Matrix<3, T> matrix() const { + Matrix<3, T> toMatrix() const { return { Vector<3, T>(T(1) - 2*pow2(_vector.y()) - 2*pow2(_vector.z()), 2*_vector.x()*_vector.y() + 2*_vector.z()*_scalar, diff --git a/src/Math/Test/ComplexTest.cpp b/src/Math/Test/ComplexTest.cpp index aa909989c..8b49bacbb 100644 --- a/src/Math/Test/ComplexTest.cpp +++ b/src/Math/Test/ComplexTest.cpp @@ -270,7 +270,7 @@ void ComplexTest::matrix() { Complex a = Complex::rotation(Deg(37.0f)); Matrix2 m = Matrix3::rotation(Deg(37.0f)).rotationScaling(); - CORRADE_COMPARE(a.matrix(), m); + CORRADE_COMPARE(a.toMatrix(), m); } void ComplexTest::transformVector() { diff --git a/src/Math/Test/DualComplexTest.cpp b/src/Math/Test/DualComplexTest.cpp index 242688540..758088379 100644 --- a/src/Math/Test/DualComplexTest.cpp +++ b/src/Math/Test/DualComplexTest.cpp @@ -215,7 +215,7 @@ void DualComplexTest::matrix() { DualComplex a = DualComplex::rotation(Deg(23.0f))*DualComplex::translation({2.0f, 3.0f}); Matrix3 m = Matrix3::rotation(Deg(23.0f))*Matrix3::translation({2.0f, 3.0f}); - CORRADE_COMPARE(a.matrix(), m); + CORRADE_COMPARE(a.toMatrix(), m); } void DualComplexTest::transformPoint() { diff --git a/src/Math/Test/DualQuaternionTest.cpp b/src/Math/Test/DualQuaternionTest.cpp index 7e64be636..72d8acb06 100644 --- a/src/Math/Test/DualQuaternionTest.cpp +++ b/src/Math/Test/DualQuaternionTest.cpp @@ -223,8 +223,8 @@ void DualQuaternionTest::matrix() { Matrix4 m = Matrix4::rotationX(Deg(23.0f))*Matrix4::translation({-1.0f, 2.0f, 3.0f}); /* Verify that negated dual quaternion gives the same transformation */ - CORRADE_COMPARE(q.matrix(), m); - CORRADE_COMPARE((-q).matrix(), m); + CORRADE_COMPARE(q.toMatrix(), m); + CORRADE_COMPARE((-q).toMatrix(), m); } void DualQuaternionTest::transformPoint() { diff --git a/src/Math/Test/QuaternionTest.cpp b/src/Math/Test/QuaternionTest.cpp index 11b28527b..de71e044a 100644 --- a/src/Math/Test/QuaternionTest.cpp +++ b/src/Math/Test/QuaternionTest.cpp @@ -277,8 +277,8 @@ void QuaternionTest::matrix() { Matrix3 m = Matrix4::rotation(Deg(37.0f), Vector3(1.0f/Constants::sqrt3())).rotationScaling(); /* Verify that negated quaternion gives the same rotation */ - CORRADE_COMPARE(q.matrix(), m); - CORRADE_COMPARE((-q).matrix(), m); + CORRADE_COMPARE(q.toMatrix(), m); + CORRADE_COMPARE((-q).toMatrix(), m); } void QuaternionTest::lerp() {