@@ -17,6 +17,7 @@ def __init__(
1717 origin : Optional [np .ndarray ] = None ,
1818 maximum : Optional [np .ndarray ] = None ,
1919 global_origin : Optional [np .ndarray ] = None ,
20+ global_maximum : Optional [np .ndarray ] = None ,
2021 nsteps : Optional [np .ndarray ] = None ,
2122 step_vector : Optional [np .ndarray ] = None ,
2223 dimensions : Optional [int ] = 3 ,
@@ -39,9 +40,12 @@ def __init__(
3940 # we want the local coordinates to start at 0
4041 # otherwise uses provided origin. This is useful for having multiple bounding boxes rela
4142 if global_origin is not None and origin is None :
42- origin = np .zeros (global_origin .shape )
43+ origin = np .zeros (np .array (global_origin ).shape )
44+ if global_maximum is not None and global_origin is not None :
45+ maximum = np .array (global_maximum ) - np .array (global_origin )
46+
4347 if maximum is None and nsteps is not None and step_vector is not None :
44- maximum = origin + nsteps * step_vector
48+ maximum = np . array ( origin ) + np . array ( nsteps ) * np . array ( step_vector )
4549 if origin is not None and global_origin is None :
4650 global_origin = np .zeros (3 )
4751 self ._origin = np .array (origin )
@@ -517,11 +521,8 @@ def project(self, xyz, inplace=False):
517521 """
518522 if inplace :
519523 xyz -= self .global_origin
520- xyz = np .clip (xyz , self .origin , self .maximum )
521524 return xyz
522- return (xyz - self .global_origin ) / np .max (
523- (self .global_maximum - self .global_origin )
524- ) # np.clip(xyz, self.origin, self.maximum)
525+ return (xyz - self .global_origin ) # np.clip(xyz, self.origin, self.maximum)
525526
526527 def scale_by_projection_factor (self , value ):
527528 return value / np .max ((self .global_maximum - self .global_origin ))
@@ -541,10 +542,9 @@ def reproject(self, xyz, inplace=False):
541542 reprojected point
542543 """
543544 if inplace :
544- xyz -= self .global_origin
545- xyz /= np .max ((self .global_maximum - self .global_origin ))
545+ xyz += self .global_origin
546546 return xyz
547- return xyz * np . max (( self . global_maximum - self . global_origin )) + self .global_origin
547+ return xyz + self .global_origin
548548
549549 def __repr__ (self ):
550550 return f"BoundingBox({ self .origin } , { self .maximum } , { self .nsteps } )"
0 commit comments