## How to convert Projective3d into Affine3d

Daniel Mohnhoff
Registered Member
Posts
1
Karma
0

### How to convert Projective3d into Affine3d

Wed Jul 24, 2013 12:59 pm
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?

Daniel
ggael
Moderator
Posts
2194
Karma
15
OS

### Re: How to convert Projective3d into Affine3d

Wed Jul 24, 2013 2:43 pm
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().

## Who is online

Registered users: alake, Baidu [Spider], bcooksley, Bing [Bot], claydoh, Exabot [Bot], garthecho, Google [Bot], koriun, Majestic-12 [Bot], north, rodsherwin, shmerl, Steve Guilford, verbalshadow, Vim, Yahoo [Bot], šumski