Browse Source

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.
pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
14460cf0f4
  1. 4
      src/Math/Complex.h
  2. 6
      src/Math/DualComplex.h
  3. 6
      src/Math/DualQuaternion.h
  4. 4
      src/Math/Quaternion.h
  5. 2
      src/Math/Test/ComplexTest.cpp
  6. 2
      src/Math/Test/DualComplexTest.cpp
  7. 4
      src/Math/Test/DualQuaternionTest.cpp
  8. 4
      src/Math/Test/QuaternionTest.cpp

4
src/Math/Complex.h

@ -155,9 +155,9 @@ template<class T> class Complex {
* b & a * b & a
* \end{pmatrix} * \end{pmatrix}
* @f] * @f]
* @see DualComplex::matrix(), Matrix3::from(const Matrix<2, T>&, const Vector2<T>&) * @see DualComplex::toMatrix(), Matrix3::from(const Matrix<2, T>&, const Vector2<T>&)
*/ */
Matrix<2, T> matrix() const { Matrix<2, T> toMatrix() const {
return {Vector<2, T>(_real, _imaginary), return {Vector<2, T>(_real, _imaginary),
Vector<2, T>(-_imaginary, _real)}; Vector<2, T>(-_imaginary, _real)};
} }

6
src/Math/DualComplex.h

@ -130,10 +130,10 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
/** /**
* @brief Convert dual complex number to transformation matrix * @brief Convert dual complex number to transformation matrix
* *
* @see Complex::matrix() * @see Complex::toMatrix()
*/ */
inline Matrix3<T> matrix() const { inline Matrix3<T> toMatrix() const {
return Matrix3<T>::from(this->real().matrix(), translation()); return Matrix3<T>::from(this->real().toMatrix(), translation());
} }
/** /**

6
src/Math/DualQuaternion.h

@ -146,10 +146,10 @@ template<class T> class DualQuaternion: public Dual<Quaternion<T>> {
/** /**
* @brief Convert dual quaternion to transformation matrix * @brief Convert dual quaternion to transformation matrix
* *
* @see Quaternion::matrix() * @see Quaternion::toMatrix()
*/ */
Matrix4<T> matrix() const { Matrix4<T> toMatrix() const {
return Matrix4<T>::from(this->real().matrix(), translation()); return Matrix4<T>::from(this->real().toMatrix(), translation());
} }
/** /**

4
src/Math/Quaternion.h

@ -204,9 +204,9 @@ template<class T> class Quaternion {
/** /**
* @brief Convert quaternion to rotation matrix * @brief Convert quaternion to rotation matrix
* *
* @see DualQuaternion::matrix(), Matrix4::from(const Matrix<3, T>&, const Vector3<T>&) * @see DualQuaternion::toMatrix(), Matrix4::from(const Matrix<3, T>&, const Vector3<T>&)
*/ */
Matrix<3, T> matrix() const { Matrix<3, T> toMatrix() const {
return { return {
Vector<3, T>(T(1) - 2*pow2(_vector.y()) - 2*pow2(_vector.z()), Vector<3, T>(T(1) - 2*pow2(_vector.y()) - 2*pow2(_vector.z()),
2*_vector.x()*_vector.y() + 2*_vector.z()*_scalar, 2*_vector.x()*_vector.y() + 2*_vector.z()*_scalar,

2
src/Math/Test/ComplexTest.cpp

@ -270,7 +270,7 @@ void ComplexTest::matrix() {
Complex a = Complex::rotation(Deg(37.0f)); Complex a = Complex::rotation(Deg(37.0f));
Matrix2 m = Matrix3::rotation(Deg(37.0f)).rotationScaling(); Matrix2 m = Matrix3::rotation(Deg(37.0f)).rotationScaling();
CORRADE_COMPARE(a.matrix(), m); CORRADE_COMPARE(a.toMatrix(), m);
} }
void ComplexTest::transformVector() { void ComplexTest::transformVector() {

2
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}); 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}); 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() { void DualComplexTest::transformPoint() {

4
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}); Matrix4 m = Matrix4::rotationX(Deg(23.0f))*Matrix4::translation({-1.0f, 2.0f, 3.0f});
/* Verify that negated dual quaternion gives the same transformation */ /* Verify that negated dual quaternion gives the same transformation */
CORRADE_COMPARE(q.matrix(), m); CORRADE_COMPARE(q.toMatrix(), m);
CORRADE_COMPARE((-q).matrix(), m); CORRADE_COMPARE((-q).toMatrix(), m);
} }
void DualQuaternionTest::transformPoint() { void DualQuaternionTest::transformPoint() {

4
src/Math/Test/QuaternionTest.cpp

@ -277,8 +277,8 @@ void QuaternionTest::matrix() {
Matrix3 m = Matrix4::rotation(Deg(37.0f), Vector3(1.0f/Constants<float>::sqrt3())).rotationScaling(); Matrix3 m = Matrix4::rotation(Deg(37.0f), Vector3(1.0f/Constants<float>::sqrt3())).rotationScaling();
/* Verify that negated quaternion gives the same rotation */ /* Verify that negated quaternion gives the same rotation */
CORRADE_COMPARE(q.matrix(), m); CORRADE_COMPARE(q.toMatrix(), m);
CORRADE_COMPARE((-q).matrix(), m); CORRADE_COMPARE((-q).toMatrix(), m);
} }
void QuaternionTest::lerp() { void QuaternionTest::lerp() {

Loading…
Cancel
Save