trimesh icon indicating copy to clipboard operation
trimesh copied to clipboard

bounds.oriented_bounds failed for less than 3 points

Open YuanWenqing opened this issue 2 years ago • 1 comments

Try bounds.oriented_bounds(points) with only 2 points, thus error like:

...
  File ".../python3.7/site-packages/trimesh/bounds.py", line 220, in oriented_bounds
    return oriented_bounds_coplanar(points)
  File ".../python3.7/site-packages/trimesh/bounds.py", line 170, in oriented_bounds_coplanar
    if np.any(np.abs(points_2d[:, 2]) > coplanar_tol):
IndexError: index 2 is out of bounds for axis 1 with size 2

The reason is that points_2d generated by points_2d = np.matmul(points_demeaned, vh.T) has a shape (2,2).

Should we check point num before calling oriented_bounds or 2 points be accepted in this method?

YuanWenqing avatar Sep 05 '23 03:09 YuanWenqing

Yeah that should probably be checked, PR's welcome!

mikedh avatar Sep 07 '23 20:09 mikedh