diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h index 8a9d9847f7b..e3d52c2bcef 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h @@ -49,7 +49,12 @@ namespace internal { { typename GT::FT norm = CGAL::approximate_sqrt( traits.compute_squared_length_3_object()(v)); - v = traits.construct_divided_vector_3_object()(v, norm); + //If the vector is small enough, approx_sqrt might return 0, and then we get nan values. + //To avoid that, we check the resulted norm. If it is 0, we don't normalize. + if(norm != 0) + { + v = traits.construct_divided_vector_3_object()(v, norm ); + } } template