# # 椭圆与单位

from basic_units import cm
import numpy as np
from matplotlib import patches
import matplotlib.pyplot as plt

xcenter, ycenter = 0.38*cm, 0.52*cm
width, height = 1e-1*cm, 3e-1*cm
angle = -30

x = 0.5 * width * np.cos(theta)
y = 0.5 * height * np.sin(theta)

R = np.array([
[np.cos(rtheta), -np.sin(rtheta)],
[np.sin(rtheta),  np.cos(rtheta)],
])

x, y = np.dot(R, np.array([x, y]))
x += xcenter
y += ycenter
fig = plt.figure()
ax.fill(x, y, alpha=0.2, facecolor='yellow',
edgecolor='yellow', linewidth=1, zorder=1)

e1 = patches.Ellipse((xcenter, ycenter), width, height,
angle=angle, linewidth=2, fill=False, zorder=2)

ax.fill(x, y, alpha=0.2, facecolor='green', edgecolor='green', zorder=1)
e2 = patches.Ellipse((xcenter, ycenter), width, height,
angle=angle, linewidth=2, fill=False, zorder=2)

fig.savefig('ellipse_compare')

fig = plt.figure()
ax.fill(x, y, alpha=0.2, facecolor='yellow',
edgecolor='yellow', linewidth=1, zorder=1)

e1 = patches.Arc((xcenter, ycenter), width, height,
angle=angle, linewidth=2, fill=False, zorder=2)

ax.fill(x, y, alpha=0.2, facecolor='green', edgecolor='green', zorder=1)
e2 = patches.Arc((xcenter, ycenter), width, height,
angle=angle, linewidth=2, fill=False, zorder=2)

fig.savefig('arc_compare')

plt.show()