Search code examples
matrixlinear-algebraeigen

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?


Solution

  • The class Transform represents either an affine or a projective transformation using homogenous calculus. For instance, an affine transformation A is composed of a linear part L and a translation t such that transforming a point p by A is equivalent to:

     p' = L * p + t
    

    Using homogeneous vectors:

     [p'] = [L t] * [p] = A * [p]
     [1 ]   [0 1]   [1]       [1]
    

    with:

     A = [L t]
         [0 1]
    

    So the linear part correspond to the top-left corner of the homogenous matrix representation. It corresponds to a mix of rotation, scaling and shearing.