flexible-collision-library / fcl

Flexible Collision Library
https://flexible-collision-library.github.io/
Other
1.39k stars 417 forks source link

Which is the rigth way to add scale to a fcl::Transform3f? #507

Closed marcobeninca71 closed 3 years ago

marcobeninca71 commented 3 years ago

Hello everybody I'm using your library in my CAD/CAM application to check for collisions. Everything looks great but I'm not sure which is the rigth way to add a scale to a fcl::Transform3f. I have a function to translate my affine transformation to fcl::Transform3f but when I try to apply a scale (using the fcl::Transform3f::scale function) I always get an error from the compiler compiling fcl::Transform3f in Eigen:

error C2338: THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS

This is because the fcl::Transform3f is not defined as Isometry Any idea? Marco

SeanCurtis-TRI commented 3 years ago

This is because the fcl::Transform3f is not defined as Isometry (emphasis mine)

I think you mean because it is defined as Isometry. This was changed a couple of years ago (#318) in order to improve performance of computing transform inverses (see Eigen documentation on Transform::inverse(). Obviously, that leaves this use case out in the cold. As scale factors mean that it's no longer an isometry.

There are two options:

  1. Change Transform back to Affine or AffineCompact. That would support your use case, but increase the cost of every inverse operation.
  2. You pre-apply your scale to the geometry and make your transform purely the pose. I don't know how hard that would be for you.
marcobeninca71 commented 3 years ago

I think you mean because it is defined as Isometry

Yes sorry it was a typo. Actually I've already apply solution 2: each time the user scale an object the geometry is recalculated applying the scale Thanks for the quick reply Marco