我想实现以下目标:
- 1)获取旋转补丁的坐标
- 2)获取补丁的所有点(这里:矩形)
- ** 我的印象是旋转的矩形在面之间没有 90 度。这只是可视化吗?
我的片段如下。旋转补丁的坐标与原始补丁的坐标相同.. 如何实现 1) 和 2) ?
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import matplotlib as mpl
from matplotlib.transforms import Affine2D
fig = plt.figure()
ax = fig.add_subplot(111)
angle = np.deg2rad(45)
r1 = patches.Rectangle((8,4), 5,3, fill=False, color="red", alpha=0.50)
r2 = patches.Rectangle((8,4), 5,3, fill=False, color="blue", alpha=0.50)
trafo = mpl.transforms.Affine2D().rotate_around(8,4,angle) + ax.transData
r2.set_transform(trafo)
ax.add_patch(r1)
ax.add_patch(r2)
plt.xlim(0,15)
plt.ylim(0,15)
plt.grid(False)
plt.show()
print(r1.get_bbox())
print(r1.get_xy())
print(r2.get_bbox()) # why are they the same as for r1?
print(r2.get_xy())
#print(r1.get_all_points()) # how to achieve it?