| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import numpy as np
- import matplotlib.pyplot as plt
- def draw_ellipse_arc(xc, yc, a, b, theta, phi1, phi2, num_points=200):
- """
- »æÖÆÍÖÔ²»¡
- Args:
- xc, yc (float): ÍÖÔ²ÖÐÐÄ×ø±ê
- a, b (float): ³¤¶Ì°ëÖá (a >= b)
- theta (float): ÍÖÔ²ÄæÊ±ÕëÐýת½Ç¶È£¨»¡¶È£©
- phi1, phi2 (float): »¡Ï߯ðʼ½Ç£¨»¡¶È£©£¬Çø¼ä [0, 2¦Ð)
- num_points (int): »æÖƾ«¶È
- """
- # Éú³É»¡Ïß²ÎÊý
- phi = np.linspace(phi1, phi2, num_points)
- # ÍÖÔ²±ê×¼·½³ÌÉϵĵã
- x = a * np.cos(phi)
- y = b * np.sin(phi)
- # Ðýת¾ØÕó
- cos_t = np.cos(theta)
- sin_t = np.sin(theta)
- xr = x * cos_t - y * sin_t + xc
- yr = x * sin_t + y * cos_t + yc
- # »æÍ¼
- plt.figure(figsize=(6,6))
- plt.plot(xr, yr, 'r-', linewidth=2)
- plt.scatter([xc], [yc], color='blue', label='Center')
- plt.axis('equal')
- plt.title("Ellipse Arc")
- plt.grid(True)
- plt.show()
- if __name__ == "__main__":
- """
- Tensor(shape=(7,), dtype=torch.float32, device=cpu, values=[1025.0, 560.0, 131.87399291992188, 116.3759994506836, -0.5879999995231628, 2.1936283111572266, 3.825697898864746])Tensor(shape=(7,),
- dtype=torch.float32, device=cpu, values=[721.0, 527.0, 121.36299896240234, 134.70399475097656, -0.02500000037252903, 2.0525598526000977, 4.132845878601074])
- 111values=[1022.0, 443.0, 88.08300018310547, 118.55699920654297, 2.7829999923706055, 5.329736709594727, 0.142518550157547])
- values=[1123.0, 923.0, 158.6739959716797, 182.2220001220703, 0.6779999732971191, 0.8875003457069397, 2.6391656398773193])
- Tensor(shape=(7,), dtype=torch.float32, device=cpu, values=[618.0, 542.0, 128.01300048828125, 141.08799743652344, 0.37400001287460327, 1.150931477546692, 5.289559364318848])\
- Tensor(shape=(7,), dtype=torch.float32, device=cpu, values=[850.0, 365.0, 159.79400634765625, 121.38099670410156, -3.078000068664551, 4.8650922775268555, 5.932548522949219])
- """
- # ʾÀý£º´Ó tensor ÖлñÈ¡µÄÖµ
- xc, yc, a, b, theta, phi1, phi2 = [
- 1022.0, 443.0, 88.08300018310547, 118.55699920654297, 2.7829999923706055, 5.329736709594727, 0.142518550157547
- ]
- draw_ellipse_arc(xc, yc, a, b, theta, phi1, phi2)
|