trimesh icon indicating copy to clipboard operation
trimesh copied to clipboard

Unexpected Extents Method for Trimesh.primitives.Box

Open fishbotics opened this issue 3 years ago • 3 comments

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!

fishbotics avatar Aug 08 '22 23:08 fishbotics

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)).

mikedh avatar Aug 08 '22 23:08 mikedh

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?

fishbotics avatar Aug 08 '22 23:08 fishbotics

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?

Agreed

csyhping avatar Aug 31 '22 10:08 csyhping