This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Remove translation from transformation

Tags: None
(comma "," separated)
s7726
Registered Member
Posts
5
Karma
0
I have a transformation that I'm using that works great. I also have a need to use only the rotation portion, inverted. Currently I'm doing this (which does what I want):

Code: Select all
Eigen::Vector4d result(point_.i(), point_.j(), point_.k(), 1);          // Populate result vector with current position
Eigen::Transform<double, 3, Eigen::Affine> rotation(m_transform);
rotation(0, 3) = 0;                                                                       // eliminate the translation component
rotation(1, 3) = 0;
rotation(2, 3) = 0;
result = rotation.inverse() * result;                                              // Rotate the point into World Space


I tried assigning the m_transform.rotation() to an AngleAxisd and then inverting and multiplying that by the result. Doesn't work due to miss match of the Matrix sizes.

Is there a way to do this better/faster?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
simply use:

m_transform.linear().inverse()
s7726
Registered Member
Posts
5
Karma
0
ggael wrote:simply use:

m_transform.linear().inverse()


Wouldn't ".linear()" return the linear portion of the matrix and then perform the inverse operation on that? Rather than zeroing out the linear (translation) portion and then inverting the result?

Edit:

ok I figured it out:

Code: Select all
        // Populate result vector with current position
        Eigen::Vector3d result(point_.i(), point_.j(), point_.k());
        // Grab the rotation component, and invert
        Eigen::Matrix3d rotation(m_transform.linear().inverse());
        // Rotate the point into World Space
        result = rotation * result;


Thanks!


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], Yahoo [Bot]