With the Eigen
C++ library, I'm having trouble understanding the Transform::linear()
function. According to the documentation, it returns the linear part of the transformation
. But what does this mean? Surely all matrix transformations are linear?
Furthermore, from seeing some examples elsewhere, it seems that the value it returns is an Eigen::Matrix3d
(or can be implicitly converted to this). To me, this suggests that it might be returning just the rotation part of the transformation, which is of length 3 (x, y and z). However, there is also a Transform::rotation()
function, which according to the documentation returns the rotation part of the transformation
.
So can somebody explain to me what Transform::linear()
actually returns?
Having come across the same question, I would like to add the following information:
As explained by @ggael, Transform::linear()
directly returns the linear part in the transformation matrix.
Transform::rotation()
returns the rotational component in the linear part. But since the linear part contains not only rotation but also reflection, shear and scaling, extracting the rotation isn't straight forward, and needs to be calculated using a singular value decomposition (SVD).
In the common case where the affine matrix is known to contain only rotation and translation then Transform::linear()
can be used to efficiently access the rotation part.
Finally, if you set the Transform
's Mode
template parameter to Isometry
, Eigen will assume only rotations and translations, and optimize calculation of the inverse transform. The latest versions of Eigen will also optimize Transform::rotation()
in that case, and directly return the linear part. Note, however, that there isn't a compact version of isometric affine matrices, where the last row isn't stored and assumed to be [0 ... 0 1].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With