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

Homogeneous transformations in different versions of Eigen

Tags: None
(comma "," separated)
aluaces
Registered Member
Posts
13
Karma
0
OS
Hi,

I have written some code that transforms several points. I have used the homogeneous() method in order to be able to multiply my dimension 3 vectors by the 4×4 transformation matrix:

Code: Select all
Eigen::Matrix4d Trans;
Eigen::Matrix3Xd points = Eigen::Matrix3Xf::Random(3,5);

Eigen::Matrix3Xd res = Trans * points.colwise().homogeneous()


My problem is that, while Eigen 3.2.1 returns a 3×n matrix, some previous version (3.0.5) returns a homogeneous 4×n matrix.
Currently, I'm solving it by picking only the first 3 rows,

Code: Select all
Eigen::Matrix3Xd res = (Trans * points.colwise().homogeneous()).topRows(3);


but I wonder if a better method is available, since I fear that the topRows() call might impose an additional performace load, considering that newer Eigen versions will not need it.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
I don't remember we changed that behavior. Anyway, you can rather use .topRows<3>() to avoid any overhead.
aluaces
Registered Member
Posts
13
Karma
0
OS
Great, thanks!. I forgot the templatized version.


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]