FanMainDrawer.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import math
  2. import core
  3. class FanMainDrawer:
  4. def __init__(self, msp, layer, gap, center, route):
  5. self.layer = layer
  6. self.msp = msp
  7. self.gap = gap
  8. self.center = center
  9. self.route = route
  10. def draw_fan_main(self):
  11. rad = 0.5 * self.gap
  12. a = math.pi / 8
  13. b = 10 / 3 * rad
  14. self.msp.add_circle(center=self.center, radius=rad, dxfattribs={"layer": f"图层{self.layer}"})
  15. A = (rad * math.cos(a) + self.center[0], rad * math.sin(a) + self.center[1])
  16. C = (rad * math.cos(a) + self.center[0], -rad * math.sin(a) + self.center[1])
  17. B = ((b / 2) / math.tan(a) + self.center[0], (b / 2) + self.center[1])
  18. D = ((b / 2) / math.tan(a) + self.center[0], -(b / 2) + self.center[1])
  19. A = core.rotate_point_around_another(A, self.center, self.route)
  20. B = core.rotate_point_around_another(B, self.center, self.route)
  21. C = core.rotate_point_around_another(C, self.center, self.route)
  22. D = core.rotate_point_around_another(D, self.center, self.route)
  23. self.msp.add_line(A, B, dxfattribs={"layer": f"图层{self.layer}"})
  24. self.msp.add_line(B, D, dxfattribs={"layer": f"图层{self.layer}"})
  25. self.msp.add_line(C, D, dxfattribs={"layer": f"图层{self.layer}"})