message: Fix computation of FrameReference for an (almost) horizontal plane
diff: @@ -434,21 +434,30 @@ namespace RINGMesh
  {
  origin = plane.origin;
  w = plane.normal;
  - auto upward_point = origin + vec3{ 0., 0., 1. };
  - vec3 v_axis_point_direction;
  - std::tie( std::ignore, v_axis_point_direction ) =
  - Distance::point_to_plane( upward_point, { w, origin } );
  - if( ( origin - v_axis_point_direction ).length() < global_epsilon )
  +
  + if( w.z > 10 * ( w.x + w.y ) )
  {
  // Case where plane is sub-horizontal
  // (v axis is set towards 3D x direction)
  auto towards_x_point = origin + vec3{ 1., 0., 0. };
  - std::tie( std::ignore, v_axis_point_direction ) =
  + vec3 u_axis_point_direction;
  + std::tie( std::ignore, u_axis_point_direction ) =
  Distance::point_to_plane( towards_x_point, { w, origin } );
  ringmesh_assert(
  - ( origin - v_axis_point_direction ).length() < global_epsilon );
  - }
  + ( origin - u_axis_point_direction ).length() > global_epsilon );
  + u = normalize( u_axis_point_direction - origin );
  + v = -cross( u, w );
  + } else {
  + // Case where plane is not sub-horizontal
  + // (v axis is set towards 3D z direction)
  + auto upward_point = origin + vec3{ 0., 0., 1. };
  + vec3 v_axis_point_direction;
  + std::tie( std::ignore, v_axis_point_direction ) =
  + Distance::point_to_plane( upward_point, { w, origin } );
  + ringmesh_assert(
  + ( origin - v_axis_point_direction ).length() > global_epsilon );
  v = normalize( v_axis_point_direction - origin );
  u = cross( v, w );
  }
  + }
  } // namespace RINGMesh
  