diff options
author | 2010-10-12 10:19:59 -0400 | |
---|---|---|
committer | 2010-10-12 10:19:59 -0400 | |
commit | 8eb0fc1e72687ad32e1bbc8a635f3834e3592ed3 (patch) | |
tree | 4ff9ec45e1dc5f627b9bac5f33da4f4a16a40b71 /Eigen/src/Geometry/Transform.h | |
parent | dbedc700123381bc478ae45897a4bb90868781dc (diff) |
remove SVD class (was bad code taked from elsewhere)
Use JacobiSVD for now.
We do plan to reintroduce a bidiagonalizing SVD asap.
Diffstat (limited to 'Eigen/src/Geometry/Transform.h')
-rw-r--r-- | Eigen/src/Geometry/Transform.h | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h index 58bb2d0c0..e8099495d 100644 --- a/Eigen/src/Geometry/Transform.h +++ b/Eigen/src/Geometry/Transform.h @@ -928,7 +928,18 @@ template<typename Scalar, int Dim, int Mode> template<typename RotationMatrixType, typename ScalingMatrixType> void Transform<Scalar,Dim,Mode>::computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling) const { - linear().svd().computeRotationScaling(rotation, scaling); + JacobiSVD<LinearMatrixType> svd(linear(), ComputeFullU | ComputeFullV); + + Scalar x = (svd.matrixU() * svd.matrixV().adjoint()).determinant(); // so x has absolute value 1 + VectorType sv(svd.singularValues()); + sv.coeffRef(0) *= x; + if(scaling) scaling->lazyAssign(svd.matrixV() * sv.asDiagonal() * svd.matrixV().adjoint()); + if(rotation) + { + LinearMatrixType m(svd.matrixU()); + m.col(0) /= x; + rotation->lazyAssign(m * svd.matrixV().adjoint()); + } } /** decomposes the linear part of the transformation as a product rotation x scaling, the scaling being @@ -946,7 +957,18 @@ template<typename Scalar, int Dim, int Mode> template<typename ScalingMatrixType, typename RotationMatrixType> void Transform<Scalar,Dim,Mode>::computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation) const { - linear().svd().computeScalingRotation(scaling, rotation); + JacobiSVD<LinearMatrixType> svd(linear(), ComputeFullU | ComputeFullV); + + Scalar x = (svd.matrixU() * svd.matrixV().adjoint()).determinant(); // so x has absolute value 1 + VectorType sv(svd.singularValues()); + sv.coeffRef(0) *= x; + if(scaling) scaling->lazyAssign(svd.matrixU() * sv.asDiagonal() * svd.matrixU().adjoint()); + if(rotation) + { + LinearMatrixType m(svd.matrixU()); + m.col(0) /= x; + rotation->lazyAssign(m * svd.matrixV().adjoint()); + } } /** Convenient method to set \c *this from a position, orientation and scale |