@@ -529,35 +529,49 @@ def to_brep(self):
529529 # Transformations
530530 # ==========================================================================
531531
532- # def transform(self, transformation):
533- # """Transform the box.
534-
535- # Parameters
536- # ----------
537- # transformation : :class:`Transformation`
538- # The transformation used to transform the Box.
539-
540- # Returns
541- # -------
542- # None
543-
544- # Examples
545- # --------
546- # >>> box = Box(Frame.worldXY(), 1.0, 2.0, 3.0)
547- # >>> frame = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15])
548- # >>> T = Transformation.from_frame(frame)
549- # >>> box.transform(T)
550-
551- # """
552- # self.frame.transform(transformation)
553- # # Always local scaling, non-uniform scaling based on frame not yet considered.
554- # Sc, _, _, _, _ = transformation.decomposed()
555- # scalex = Sc[0, 0]
556- # scaley = Sc[1, 1]
557- # scalez = Sc[2, 2]
558- # self.xsize *= scalex
559- # self.ysize *= scaley
560- # self.zsize *= scalez
532+ def transform (self , transformation ):
533+ """Transform the box.
534+
535+ Parameters
536+ ----------
537+ transformation : :class:`Transformation`
538+ The transformation used to transform the Box.
539+
540+ Returns
541+ -------
542+ None
543+
544+ Examples
545+ --------
546+ >>> from compas.geometry import Frame, Transformation, Scale
547+ >>> box = Box(Frame.worldXY(), 1.0, 2.0, 3.0)
548+ >>> frame = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15])
549+ >>> T = Transformation.from_frame(frame)
550+ >>> box.transform(T)
551+ >>> S = Scale.from_factors([2.0, 3.0, 4.0])
552+ >>> box = Box(1.0, 2.0, 3.0)
553+ >>> box.transform(S)
554+ >>> box.xsize
555+ 2.0
556+ >>> box.ysize
557+ 6.0
558+ >>> box.zsize
559+ 12.0
560+
561+ """
562+ # Extract scale component from the transformation
563+ Sc , _ , _ , _ , _ = transformation .decomposed ()
564+ scale_x = Sc .matrix [0 ][0 ]
565+ scale_y = Sc .matrix [1 ][1 ]
566+ scale_z = Sc .matrix [2 ][2 ]
567+
568+ # Apply scaling to dimensions
569+ self .xsize *= scale_x
570+ self .ysize *= scale_y
571+ self .zsize *= scale_z
572+
573+ # Apply transformation to frame
574+ self .frame .transform (transformation )
561575
562576 def scale (self , x , y = None , z = None ):
563577 """Scale the box.
0 commit comments