Browse Source

Math: attempt to deconfuse orthogonalization/orthonormalization a bit.

pull/427/merge
Vladimír Vondruš 6 years ago
parent
commit
22118c754d
  1. 18
      src/Magnum/Math/Algorithms/GramSchmidt.h
  2. 8
      src/Magnum/Math/Matrix.h

18
src/Magnum/Math/Algorithms/GramSchmidt.h

@ -53,8 +53,15 @@ the process works as follows, with @f$ \boldsymbol{v}_k @f$ being columns of
Note that the above is not performed directly due to numerical instability, Note that the above is not performed directly due to numerical instability,
the stable [modified Gram-Schmidt](https://en.wikipedia.org/wiki/Gram–Schmidt_process#Numerical_stability) the stable [modified Gram-Schmidt](https://en.wikipedia.org/wiki/Gram–Schmidt_process#Numerical_stability)
algorithm is used instead. algorithm is used instead.
@see @ref gramSchmidtOrthogonalize(), @ref gramSchmidtOrthonormalizeInPlace(),
@ref Vector::projected() @attention Note that while this operation produces orthogonal column vectors,
it doesn't produce an [orthogonal matrix](https://en.wikipedia.org/wiki/Orthogonal_matrix)
--- an orthogonal matrix, as confusing as it may sound, has its column
vectors normalized. To produce an orthogonal matrix (for which
@ref Matrix::isOrthogonal() returns @cpp true @ce), use
@ref gramSchmidtOrthonormalizeInPlace() instead.
@see @ref gramSchmidtOrthogonalize(), @ref Vector::projected()
*/ */
template<std::size_t cols, std::size_t rows, class T> void gramSchmidtOrthogonalizeInPlace(RectangularMatrix<cols, rows, T>& matrix) { template<std::size_t cols, std::size_t rows, class T> void gramSchmidtOrthogonalizeInPlace(RectangularMatrix<cols, rows, T>& matrix) {
static_assert(cols <= rows, "Unsupported matrix aspect ratio"); static_assert(cols <= rows, "Unsupported matrix aspect ratio");
@ -69,6 +76,13 @@ template<std::size_t cols, std::size_t rows, class T> void gramSchmidtOrthogonal
Unlike @ref gramSchmidtOrthogonalizeInPlace() returns the modified matrix Unlike @ref gramSchmidtOrthogonalizeInPlace() returns the modified matrix
instead of performing the orthogonalization in-place. instead of performing the orthogonalization in-place.
@attention Note that while this operation produces orthogonal column vectors,
it doesn't produce an [orthogonal matrix](https://en.wikipedia.org/wiki/Orthogonal_matrix)
--- an orthogonal matrix, as confusing as it may sound, has its column
vectors normalized. To produce an orthogonal matrix (for which
@ref Matrix::isOrthogonal() returns @cpp true @ce), use
@ref gramSchmidtOrthonormalize() instead.
*/ */
template<std::size_t cols, std::size_t rows, class T> RectangularMatrix<cols, rows, T> gramSchmidtOrthogonalize(RectangularMatrix<cols, rows, T> matrix) { template<std::size_t cols, std::size_t rows, class T> RectangularMatrix<cols, rows, T> gramSchmidtOrthogonalize(RectangularMatrix<cols, rows, T> matrix) {
gramSchmidtOrthogonalizeInPlace(matrix); gramSchmidtOrthogonalizeInPlace(matrix);

8
src/Magnum/Math/Matrix.h

@ -122,12 +122,16 @@ template<std::size_t size, class T> class Matrix: public RectangularMatrix<size,
/** /**
* @brief Whether the matrix is orthogonal * @brief Whether the matrix is orthogonal
* *
* The matrix is orthogonal if its transpose is equal to its inverse: @f[ * Returns @cpp true @ce if all basis vectors have unit length and are
* orthogonal to each other. In other words, when its transpose is
* equal to its inverse: @f[
* Q^T = Q^{-1} * Q^T = Q^{-1}
* @f] * @f]
* @see @ref transposed(), @ref inverted(), * @see @ref transposed(), @ref inverted(),
* @ref Matrix3::isRigidTransformation(), * @ref Matrix3::isRigidTransformation(),
* @ref Matrix4::isRigidTransformation() * @ref Matrix4::isRigidTransformation(),
* @ref Algorithms::gramSchmidtOrthogonalizeInPlace(),
* @ref Algorithms::gramSchmidtOrthonormalizeInPlace()
*/ */
bool isOrthogonal() const; bool isOrthogonal() const;

Loading…
Cancel
Save