Registered Member
|
Hey,
I am faced with the following problem: I have to assemble one gigantic affine linear transform and have to do in the middle a non standard operation. At this point this code works, but is very non-Eigen eye candy: Matrix4f mE; Affine3f t; t = Affine3f(Translation3f(pos[ 0 ], pos[ 1 ], pos[ 2 ]) * Translation3f(cen[ 0 ], cen[ 1 ], cen[ 2 ]) * Translation3f(centerX, centerY, 0.0f) * AngleAxisf(rot[0], Vector3f::UnitX()) * AngleAxisf(rot[1], Vector3f::UnitY()) * AngleAxisf(rot[2], Vector3f::UnitZ()) * Scaling(scl[0], scl[1], scl[2])).matrix() * mE * Affine3f( Translation3f(-centerX, -centerY, 0) * Translation3f(-cen[0], -cen[1], -cen[2]) ).matrix(); Is there a way to avoid the parenthesization and conversion into affine3f and matrices? |
Moderator
|
Using Affine3f(mE) is simple and probably cleaner. Another solution is do something like:
t = .... * (mE * ....); and declare mE as a 3x4 matrix such that (mE * ....) returns an Affine3f and not a Projective3f. You can also use mE.topRows<3>(). The parenthesis is important, because here (.... * mE) would mean applying the transformation to the set of homogeneous vectors stored in mE and so you would get a Matrix4f. |
Registered Member
|
Thanks for the reply.
I did wind up using Affine3f(mE) in the expression (more like mE is directly an affine) |
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]