Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Eigen::Affine3d #13

Open
ahundt opened this issue Oct 17, 2017 · 2 comments
Open

Adding Eigen::Affine3d #13

ahundt opened this issue Oct 17, 2017 · 2 comments

Comments

@ahundt
Copy link

ahundt commented Oct 17, 2017

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?

@ahundt ahundt changed the title Adding Eigen::Transform Adding Eigen::Affine3d Oct 18, 2017
@gergondet
Copy link
Member

You'd need to do 2 things:

  • c_eigen.pxd to declare Eigen::Transform<T, dim. mode> and the operations you want to access and typedef for Affine3d (you could also just declare the Affine3d class and the functions you want but doing so with Transform is the better solution)
  • Write code in generate_eigen_pyx.py that writes the binding for a specific instance of Transform (e.g. Affine3d) and append that output to the generated eigen.pyx (around L. 668)
  • Add the declaration to eigen.pxd (also generated, around L. 686 of generate_eigen_pyx.py)

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
Copy link
Collaborator

haudren commented Oct 20, 2017

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants