Reply to topic

How to convert Projective3d into Affine3d

Daniel Mohnhoff
Registered Member
Hello everyone,

I am working on some legacy code that uses Eigen for 3D math.
I have a part of code that delivers a 3D transformation matrix as Projective3d (for unknown reasons, should have been ok with Affine3D) which has to be passed to another part that requires the transformation matrix to be an Affine3d.
I 've seen from other parts, that it is possible to assign Affine3d to Projective3d but when trying it the other way around, it throws compiler error 'YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION'. I have looked into transform.h but could not see any obvious way to do the conversion, neither did I find examples.

Basically I do not care about the mode and the additional properties of Projective3d (i am sure, we don't use them, at least outside projection tranformation), I just need this matrix to be multiplied by other transformation matrices (Affine3d) and passed to a GLSL shader program as a modelview matrix.

Any ideas ho to solve this are greatly appreciated. :)

As a more general question, what would be the most feasible class to store transformation data, e.g. in a scene graph structure?

Thanks in advance
User avatar ggael
You can bypass this with aff.matrix() = proj.matrix(). If you are unsure that proj.matrix().row(3)==(0,0,0,1), then better copy the top rows only: aff.matrix().topRows<3>() = proj.matrix().topRows<3>().

Perhaps we could have an .affine() accessor like .linear() and .translation().

Reply to topic


Who is online

Registered users: alvinwong, Baidu [Spider], Bing [Bot], einar, Exabot [Bot], Google [Bot], jarhin, miltonmendez, peje, Yahoo [Bot]