| 1133 | template<typename Scalar, int Dim, int Mode, int Options> |
| 1134 | template<typename ScalingMatrixType, typename RotationMatrixType> |
| 1135 | EIGEN_DEVICE_FUNC void Transform<Scalar,Dim,Mode,Options>::computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation) const |
| 1136 | { |
| 1137 | // Note that JacobiSVD is faster than BDCSVD for small matrices. |
| 1138 | JacobiSVD<LinearMatrixType, ComputeFullU | ComputeFullV> svd(linear()); |
| 1139 | |
| 1140 | Scalar x = (svd.matrixU() * svd.matrixV().adjoint()).determinant() < Scalar(0) ? Scalar(-1) : Scalar(1); // so x has absolute value 1 |
| 1141 | VectorType sv(svd.singularValues()); |
| 1142 | sv.coeffRef(Dim-1) *= x; |
| 1143 | if(scaling) *scaling = svd.matrixU() * sv.asDiagonal() * svd.matrixU().adjoint(); |
| 1144 | if(rotation) |
| 1145 | { |
| 1146 | LinearMatrixType m(svd.matrixU()); |
| 1147 | m.col(Dim-1) *= x; |
| 1148 | *rotation = m * svd.matrixV().adjoint(); |
| 1149 | } |
| 1150 | } |
| 1151 | |
| 1152 | /** Convenient method to set \c *this from a position, orientation and scale |
| 1153 | * of a 3D object. |
nothing calls this directly
no test coverage detected