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