jrl-umi3218 / Eigen3ToPython

Provide Eigen3 to numpy conversion
BSD 2-Clause "Simplified" License
49 stars 10 forks source link

Adding Eigen::Affine3d #13

Open ahundt opened 6 years ago

ahundt commented 6 years ago

I'm thinking of adding Eigen::Affine3d https://github.com/RLovelett/eigen/blob/master/Eigen/src/Geometry/Transform.h to this, could you advise me on where I'll need to make changes?

gergondet commented 6 years ago

You'd need to do 2 things:

Note: for the declaration of mode you'll want to do something similar to the way dynamic, one, two, three, four and six are defined but using Eigen's nameds instead, e.g.

ctypedef int Affine "Affine"

I think @haudren tried this or something related in the past as well (but I might be remembering wrong)

haudren commented 6 years ago

@gergondet : Yes I tried to use those things in the past, but it was in a bit more complex situation.

Here you are in a typical "bind an enum" case. Thus you can use any of the following things:

cdef extern int one "eins", two "zwei"
cdef extern float three "drei"

cdef struct spam "SPAM":
    int i "eye"

cdef enum surprise "inquisition":
    first "alpha"
    second "beta" = 3

(taken from here )

I would recommend going with the third style, as it neatly maps the Python from the C++ (and nobody expects the Spanish inquisition). Note that the enum style automatically assumes that the values are ints.