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 { template<class T> Matrix2x2<T> Matrix3<T>::rotation() const {
Matrix2x2<T> rotation{(*this)[0].xy().normalized(), Matrix2x2<T> rotationShear = this->rotationShear();
(*this)[1].xy().normalized()}; CORRADE_DEBUG_ASSERT(rotationShear.isOrthogonal(),
CORRADE_DEBUG_ASSERT(rotation.isOrthogonal(), "Math::Matrix3::rotation(): the normalized rotation part is not orthogonal:" << Debug::newline << rotationShear, {});
"Math::Matrix3::rotation(): the normalized rotation part is not orthogonal:" << Debug::newline << rotation, {}); return rotationShear;
return rotation;
} }
template<class T> Matrix2x2<T> Matrix3<T>::rotationNormalized() const { template<class T> Matrix2x2<T> Matrix3<T>::rotationNormalized() const {
Matrix2x2<T> rotation{(*this)[0].xy(), Matrix2x2<T> rotationScaling = this->rotationScaling();
(*this)[1].xy()}; CORRADE_DEBUG_ASSERT(rotationScaling.isOrthogonal(),
CORRADE_DEBUG_ASSERT(rotation.isOrthogonal(), "Math::Matrix3::rotationNormalized(): the rotation part is not orthogonal:" << Debug::newline << rotationScaling, {});
"Math::Matrix3::rotationNormalized(): the rotation part is not orthogonal:" << Debug::newline << rotation, {}); return rotationScaling;
return rotation;
} }
template<class T> T Matrix3<T>::uniformScalingSquared() const { 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 { template<class T> Matrix3x3<T> Matrix4<T>::rotation() const {
Matrix3x3<T> rotation{(*this)[0].xyz().normalized(), Matrix3x3<T> rotationShear = this->rotationShear();
(*this)[1].xyz().normalized(), CORRADE_DEBUG_ASSERT(rotationShear.isOrthogonal(),
(*this)[2].xyz().normalized()}; "Math::Matrix4::rotation(): the normalized rotation part is not orthogonal:" << Debug::newline << rotationShear, {});
CORRADE_DEBUG_ASSERT(rotation.isOrthogonal(), return rotationShear;
"Math::Matrix4::rotation(): the normalized rotation part is not orthogonal:" << Debug::newline << rotation, {});
return rotation;
} }
template<class T> Matrix3x3<T> Matrix4<T>::rotationNormalized() const { template<class T> Matrix3x3<T> Matrix4<T>::rotationNormalized() const {
Matrix3x3<T> rotation{(*this)[0].xyz(), Matrix3x3<T> rotationScaling = this->rotationScaling();
(*this)[1].xyz(), CORRADE_DEBUG_ASSERT(rotationScaling.isOrthogonal(),
(*this)[2].xyz()}; "Math::Matrix4::rotationNormalized(): the rotation part is not orthogonal:" << Debug::newline << rotationScaling, {});
CORRADE_DEBUG_ASSERT(rotation.isOrthogonal(), return rotationScaling;
"Math::Matrix4::rotationNormalized(): the rotation part is not orthogonal:" << Debug::newline << rotation, {});
return rotation;
} }
template<class T> T Matrix4<T>::uniformScalingSquared() const { template<class T> T Matrix4<T>::uniformScalingSquared() const {

Loading…
Cancel
Save