|
|
|
|
@ -227,8 +227,8 @@ template<class T> class Matrix4: public Matrix<4, T> {
|
|
|
|
|
* |
|
|
|
|
* Upper-left 3x3 part of the matrix. |
|
|
|
|
* @see from(const Matrix<3, T>&, const Vector3&), rotation() const, |
|
|
|
|
* rotationNormalized(), rotation(T, const Vector3&), |
|
|
|
|
* Matrix3::rotationScaling() const |
|
|
|
|
* rotationNormalized(), @ref uniformScaling(), |
|
|
|
|
* rotation(T, const Vector3&), Matrix3::rotationScaling() const |
|
|
|
|
*/ |
|
|
|
|
/* Not Matrix3, because it is for affine 2D transformations */ |
|
|
|
|
constexpr Matrix<3, T> rotationScaling() const { |
|
|
|
|
@ -242,7 +242,8 @@ template<class T> class Matrix4: public Matrix<4, T> {
|
|
|
|
|
* |
|
|
|
|
* Similar to @ref rotationScaling(), but additionally checks that the |
|
|
|
|
* base vectors are normalized. |
|
|
|
|
* @see rotation() const, @ref Matrix3::rotationNormalized() |
|
|
|
|
* @see rotation() const, @ref uniformScaling(), |
|
|
|
|
* @ref Matrix3::rotationNormalized() |
|
|
|
|
* @todo assert also orthogonality or this is good enough? |
|
|
|
|
*/ |
|
|
|
|
/* Not Matrix3, because it is for affine 2D transformations */ |
|
|
|
|
@ -259,13 +260,23 @@ template<class T> class Matrix4: public Matrix<4, T> {
|
|
|
|
|
* |
|
|
|
|
* Normalized upper-left 3x3 part of the matrix. |
|
|
|
|
* @see rotationNormalized(), rotationScaling() const, |
|
|
|
|
* rotation(T, const Vector3&), Matrix3::rotation() const |
|
|
|
|
* @ref uniformScaling(), rotation(T, const Vector3&), |
|
|
|
|
* Matrix3::rotation() const |
|
|
|
|
* @todo assert uniform scaling (otherwise this would be garbage) |
|
|
|
|
*/ |
|
|
|
|
/* Not Matrix3, because it is for affine 2D transformations */ |
|
|
|
|
Matrix<3, T> rotation() const; |
|
|
|
|
|
|
|
|
|
/** @todo uniform scaling extraction */ |
|
|
|
|
/**
|
|
|
|
|
* @brief Uniform scaling part of the matrix |
|
|
|
|
* |
|
|
|
|
* Length of vectors in upper-left 3x3 part of the matrix. Expects that |
|
|
|
|
* the scaling is the same in all axes. |
|
|
|
|
* @see @ref rotationScaling(), @ref rotation(), |
|
|
|
|
* @ref rotationNormalized(), @ref scaling(const Vector3&), |
|
|
|
|
* @ref Matrix3::uniformScaling() |
|
|
|
|
*/ |
|
|
|
|
T uniformScaling() const; |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Right-pointing 3D vector |
|
|
|
|
@ -446,6 +457,14 @@ template<class T> inline Matrix<3, T> Matrix4<T>::rotation() const {
|
|
|
|
|
(*this)[2].xyz().normalized()}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template<class T> T Matrix4<T>::uniformScaling() const { |
|
|
|
|
const T scalingSquared = (*this)[0].xyz().dot(); |
|
|
|
|
CORRADE_ASSERT(TypeTraits<T>::equals((*this)[1].xyz().dot(), scalingSquared) && |
|
|
|
|
TypeTraits<T>::equals((*this)[2].xyz().dot(), scalingSquared), |
|
|
|
|
"Math::Matrix4::uniformScaling(): the matrix doesn't have uniform scaling", {}); |
|
|
|
|
return std::sqrt(scalingSquared); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template<class T> Matrix4<T> Matrix4<T>::invertedRigid() const { |
|
|
|
|
CORRADE_ASSERT(isRigidTransformation(), |
|
|
|
|
"Math::Matrix4::invertedRigid(): the matrix doesn't represent rigid transformation", {}); |
|
|
|
|
|