MCPcopy Create free account
hub / github.com/TinyMPC/TinyMPC / computeScalingRotation

Method computeScalingRotation

include/Eigen/Eigen/src/Geometry/Transform.h:1135–1150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1133template<typename Scalar, int Dim, int Mode, int Options>
1134template<typename ScalingMatrixType, typename RotationMatrixType>
1135EIGEN_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.

Callers

nothing calls this directly

Calls 5

asDiagonalMethod · 0.80
determinantMethod · 0.45
matrixUMethod · 0.45
adjointMethod · 0.45
colMethod · 0.45

Tested by

no test coverage detected