trimesh
trimesh copied to clipboard
Add support for float inputs in trimesh.grouping.boolean_rows
The function trimesh.grouping.boolean_rows is described as a very general function to find matching rows in arbitrary matrices but internally it converts the arrays to the type np.int64
.
Therefore, if the input arrays have type np.float32
or np.float64
the decimal digits are discarded leading to a completely different behaviour.
Would it be possible to generalise the function to compare the binary representation of rows of whatever datatype?
Example to reproduce
Trimesh version: 4.0.7
>>> import trimesh
>>> import numpy as np
>>> v1 = np.linspace(0,1,6, endpoint=False).reshape(2,3)
>>> v2 = np.linspace(0,2,12, endpoint=False).reshape(4,3)
>>> trimesh.grouping.boolean_rows(v1, v2)
array([[0, 0, 0]])
A simple solution should be to just remove the parameter dtype
inside the call to np.asanyarray
.
https://github.com/mikedh/trimesh/blob/7c90a94a427e7af1152bdc2dfb3e6ab6cfd2826c/trimesh/grouping.py#L604