代码拉取完成,页面将自动刷新
import matplotlib.pyplot as plt
import math
def draw_parallel_lines_and_angles(corresponding_angles, alternate_interior_angles):
# 定义两条平行线及其交于第三条直线的位置
x1 = -5
y1 = 0
x2 = 5
y2 = 0
x3 = 0
y3 = 3
fig, ax = plt.subplots(figsize=(6, 6))
# 绘制两条平行线
ax.plot([x1, x2], [y1, y1], 'k-', label='Parallel Line 1')
ax.plot([x1, x2], [y3, y3], 'k--', label='Parallel Line 2')
# 绘制与平行线相交的第三条直线
ax.plot([x1, x3], [y1, y3], 'r-', label='Transversal')
# 计算并标注角度
for i in range(2):
# 同位角标注
angle_corresponding_rad = corresponding_angles[i]
x4 = x3 + 1.5 * math.cos(angle_corresponding_rad)
y4 = y3 + 1.5 * math.sin(angle_corresponding_rad)
ax.plot([x3, x4], [y3, y4], 'b-')
ax.annotate(f'{math.degrees(angle_corresponding_rad):.1f}°', xy=(x4, y4),
xytext=(x4 + 0.5, y4 + 0.5),
arrowprops=dict(facecolor='black', shrink=0.05))
# 内错角标注
angle_alternate_rad = alternate_interior_angles[i]
x5 = x2 if i == 0 else x1
y5 = y3 + 1.5 * math.sin(angle_alternate_rad)
ax.plot([x5, x3], [y3, y5], 'g-')
ax.annotate(f'{math.degrees(angle_alternate_rad):.1f}°', xy=(x3, y5),
xytext=(x3 + 0.5, y5 + 0.5),
arrowprops=dict(facecolor='black', shrink=0.05))
# 添加图例和坐标轴标签
ax.legend()
ax.set_xlim([-6, 6])
ax.set_ylim([-1, 6])
ax.axis('off')
# 显示图形
plt.show()
# 示例数据:假设两组同位角和内错角都是相等的
corresponding_angles = [math.pi / 4, math.pi / 4] # 同位角
alternate_interior_angles = [math.pi / 3, math.pi / 3] # 内错角
draw_parallel_lines_and_angles(corresponding_angles, alternate_interior_angles)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。