trimesh
trimesh copied to clipboard
Unexpected Extents Method for Trimesh.primitives.Box
Hi all,
I'm seeing some unexpected behavior (to me, at least) when I call .extents on a rotated box.
As an example:
import trimesh
import trimesh.transformations as tra
extents = [0.7, 0.7, 0.04]
position = [0, 0.09665476220843926, 1.1074873734152917]
angles = [-0.7853981633974483, 0.0, 0.0]
box = trimesh.primitives.Box(
extents=extents,
transform=tra.compose_matrix(translate=position, angles=angles)
)
print(box.extents)
print(box.primitive.extents)
This first prints array([0.7 , 0.52325902, 0.52325902]) and then prints the expected TrackedArray([0.7 , 0.7 , 0.04])
Can someone explain what's going on?
Thanks!
Hey, the mutable box.primitive.extents is the pre-transform size of the box used for creation, and box.extents is the post-transform size of the axis-aligned bounding box of the resulting geometry (i.e ~= box.vertices.ptp(axis=0)).
Thanks Mike! After going through the base class, this makes sense.
I think the double use of the term extents is confusing--do you think it could be changed to be something unique to the primitive Box class? Or at least, the distinction between the duplicate terms could make an appearance in the documentation.
Are there any other primitive properties that would have similar duplication?
Thanks Mike! After going through the base class, this makes sense.
I think the double use of the term
extentsis confusing--do you think it could be changed to be something unique to the primitive Box class? Or at least, the distinction between the duplicate terms could make an appearance in the documentation.Are there any other primitive properties that would have similar duplication?
Agreed