Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does Transform::linear() return in the Eigen library?

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?

like image 217
Karnivaurus Avatar asked Feb 15 '16 18:02

Karnivaurus


1 Answers

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].

like image 197
Daniel Gehriger Avatar answered Sep 29 '22 21:09

Daniel Gehriger