FanSystemDrawer.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import math
  2. from ezdxf import math as mt
  3. from core import rotate_point_around_another
  4. class FanSystemDrawer:
  5. def __init__(self, msp, gap, center, route):
  6. self.msp = msp
  7. self.gap = gap
  8. self.center = center
  9. self.route = route
  10. def draw_fan_system(self):
  11. rad = self.gap / 2
  12. carc = mt.arc.ConstructionArc()
  13. # 初始化扇形起始和结束点
  14. fan_a_start = (self.center[0], self.center[1] + rad)
  15. fan_b_start = (self.center[0] - rad / 2, self.center[1] + rad / 2)
  16. # 绘制中心圆
  17. self.msp.add_circle(self.center, rad)
  18. # 绘制每个扇形
  19. for i in range(3):
  20. fan_a = rotate_point_around_another(fan_a_start, self.center, self.route + i * (2 / 3) * math.pi)
  21. fan_b = rotate_point_around_another(fan_b_start, self.center, self.route + i * (2 / 3) * math.pi)
  22. fan_carc_3p = carc.from_3p(start_point=fan_a, def_point=fan_b, end_point=self.center)
  23. self.msp.add_arc(center=fan_carc_3p.center, radius=fan_carc_3p.radius,
  24. start_angle=fan_carc_3p.start_angle, end_angle=fan_carc_3p.end_angle)
  25. # 绘制中心到扇形起点的线段
  26. self.msp.add_line(fan_a, self.center)