Browse Source

Math: simplify internals of Matrix[34]::rotation{,Normalized}().

It does exactly what these functions do, so delegate to them.
pull/168/head
Vladimír Vondruš 2 years ago
parent
commit
83c7a8f6c3
  1. 18
      src/Magnum/Math/Matrix3.h
  2. 20
      src/Magnum/Math/Matrix4.h

18
src/Magnum/Math/Matrix3.h

@ -766,19 +766,17 @@ template<class T> Matrix3<T> Matrix3<T>::projection(const Vector2<T>& bottomLeft
}
template<class T> Matrix2x2<T> Matrix3<T>::rotation() const {
Matrix2x2<T> rotation{(*this)[0].xy().normalized(),
(*this)[1].xy().normalized()};
CORRADE_DEBUG_ASSERT(rotation.isOrthogonal(),
"Math::Matrix3::rotation(): the normalized rotation part is not orthogonal:" << Debug::newline << rotation, {});
return rotation;
Matrix2x2<T> rotationShear = this->rotationShear();
CORRADE_DEBUG_ASSERT(rotationShear.isOrthogonal(),
"Math::Matrix3::rotation(): the normalized rotation part is not orthogonal:" << Debug::newline << rotationShear, {});
return rotationShear;
}
template<class T> Matrix2x2<T> Matrix3<T>::rotationNormalized() const {
Matrix2x2<T> rotation{(*this)[0].xy(),
(*this)[1].xy()};
CORRADE_DEBUG_ASSERT(rotation.isOrthogonal(),
"Math::Matrix3::rotationNormalized(): the rotation part is not orthogonal:" << Debug::newline << rotation, {});
return rotation;
Matrix2x2<T> rotationScaling = this->rotationScaling();
CORRADE_DEBUG_ASSERT(rotationScaling.isOrthogonal(),
"Math::Matrix3::rotationNormalized(): the rotation part is not orthogonal:" << Debug::newline << rotationScaling, {});
return rotationScaling;
}
template<class T> T Matrix3<T>::uniformScalingSquared() const {

20
src/Magnum/Math/Matrix4.h

@ -1328,21 +1328,17 @@ template<class T> Matrix4<T> Matrix4<T>::lookAt(const Vector3<T>& eye, const Vec
}
template<class T> Matrix3x3<T> Matrix4<T>::rotation() const {
Matrix3x3<T> rotation{(*this)[0].xyz().normalized(),
(*this)[1].xyz().normalized(),
(*this)[2].xyz().normalized()};
CORRADE_DEBUG_ASSERT(rotation.isOrthogonal(),
"Math::Matrix4::rotation(): the normalized rotation part is not orthogonal:" << Debug::newline << rotation, {});
return rotation;
Matrix3x3<T> rotationShear = this->rotationShear();
CORRADE_DEBUG_ASSERT(rotationShear.isOrthogonal(),
"Math::Matrix4::rotation(): the normalized rotation part is not orthogonal:" << Debug::newline << rotationShear, {});
return rotationShear;
}
template<class T> Matrix3x3<T> Matrix4<T>::rotationNormalized() const {
Matrix3x3<T> rotation{(*this)[0].xyz(),
(*this)[1].xyz(),
(*this)[2].xyz()};
CORRADE_DEBUG_ASSERT(rotation.isOrthogonal(),
"Math::Matrix4::rotationNormalized(): the rotation part is not orthogonal:" << Debug::newline << rotation, {});
return rotation;
Matrix3x3<T> rotationScaling = this->rotationScaling();
CORRADE_DEBUG_ASSERT(rotationScaling.isOrthogonal(),
"Math::Matrix4::rotationNormalized(): the rotation part is not orthogonal:" << Debug::newline << rotationScaling, {});
return rotationScaling;
}
template<class T> T Matrix4<T>::uniformScalingSquared() const {

Loading…
Cancel
Save