moveit / geometric_shapes

Representation of geometric shapes
57 stars 92 forks source link

Use eigen to compute angle between vertex normals to avoid nans #246

Closed mlanighan closed 1 month ago

mlanighan commented 1 month ago

This PR resolves a lingering item with https://github.com/moveit/geometric_shapes/issues/76 that caused downstream issues in FCL with certain meshes that spewed eigen: too many iterations in Jacobi transform.

As hinted by https://github.com/flexible-collision-library/fcl/issues/190, we tracked this down to nans being introduced due to floating point imprecision in line 551 return std::acos(vec1.dot(vec2) / (vec1_norm * vec2_norm));

Rather than introduce guards to sanitize input/output, use eigen to compute the angle directly-in our internal testing the error with FCL no longer appears with this change.

When this is accepted we can incorporate the fix into https://github.com/moveit/geometric_shapes/pull/240