@@ -2373,7 +2373,7 @@ def _get_translate_rotate_transform(self):
2373
2373
rect = self .to_draw
2374
2374
x0 , y0 , width , height , angle = self ._rect_properties
2375
2375
return (transforms .Affine2D ()
2376
- .rotate_deg_around (x0 , y0 , - np . rad2deg ( angle ) )
2376
+ .rotate_around (x0 , y0 , - angle )
2377
2377
.translate (- x0 , - y0 ))
2378
2378
2379
2379
def _press (self , event ):
@@ -2554,32 +2554,29 @@ def _rect_properties(self):
2554
2554
def corners (self ):
2555
2555
"""Corners of rectangle from lower left, moving clockwise."""
2556
2556
x0 , y0 , width , height , angle = self ._rect_properties
2557
- x = np .array ([0 , width , width , 0 ])
2558
- y = np .array ([0 , 0 , height , height ])
2559
- xc = x0 + (np .cos (angle ) * x - np .sin (angle ) * y )
2560
- yc = y0 + (np .sin (angle ) * x + np .cos (angle ) * y )
2561
- return tuple (xc ), tuple (yc )
2557
+ xy = np .array ([[0 , width , width , 0 ],
2558
+ [0 , 0 , height , height ]])
2559
+ xyc = self ._get_translate_rotate_transform ().inverted ().transform (xy .T )
2560
+ return tuple (xyc [:, 0 ]), tuple (xyc [:, 1 ])
2562
2561
2563
2562
@property
2564
2563
def edge_centers (self ):
2565
2564
"""Midpoint of rectangle edges from left, moving anti-clockwise."""
2566
2565
x0 , y0 , width , height , angle = self ._rect_properties
2567
2566
w = width / 2.
2568
2567
h = height / 2.
2569
- x = np .array ([0 , w , width , w ])
2570
- y = np .array ([h , 0 , h , height ])
2571
- xe = x0 + (np .cos (angle ) * x - np .sin (angle ) * y )
2572
- ye = y0 + (np .sin (angle ) * x + np .cos (angle ) * y )
2573
- return tuple (xe ), tuple (ye )
2568
+ xy = np .array ([[0 , w , width , w ],
2569
+ [h , 0 , h , height ]])
2570
+ xye = self ._get_translate_rotate_transform ().inverted ().transform (xy .T )
2571
+ return tuple (xye [:, 0 ]), tuple (xye [:, 1 ])
2574
2572
2575
2573
@property
2576
2574
def center (self ):
2577
2575
"""Center of rectangle."""
2578
2576
x0 , y0 , width , height , angle = self ._rect_properties
2579
- hw , hh = width / 2 , height / 2
2580
- dx = np .cos (angle ) * hw - np .sin (angle ) * hh
2581
- dy = np .sin (angle ) * hw + np .cos (angle ) * hh
2582
- return x0 + dx , y0 + dy
2577
+ xy = np .array ([width / 2 , height / 2 ])
2578
+ xyc = self ._get_translate_rotate_transform ().inverted ().transform (xy )
2579
+ return tuple (xyc )
2583
2580
2584
2581
@property
2585
2582
def extents (self ):
0 commit comments