car.yml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. !!omap
  2. - name: car
  3. - parts:
  4. - name: head
  5. shapes:
  6. libraries: ['from math import tan, radians, sin, cos', 'from pysketcher import *']
  7. - name: constants
  8. shapes:
  9. R: 1.0 # radius of wheel
  10. L: 4.0 # distance between wheels
  11. H: 2.0 # height of vehicle body
  12. w_1: 5.0 # position of front wheel
  13. - name: frame
  14. shapes:
  15. xmax: w_1 + 2*L + 3*R
  16. setframe:
  17. action: drawing_tool.set_coordinate_system(xmin=0, xmax=xmax,
  18. ymin=-1, ymax=2*R + 3*H,
  19. axis=False)
  20. wheel1: |
  21. Composition({'wheel': Circle(center=(w_1, R), radius=R),
  22. 'cross': Composition({'cross1': Line((w_1,0),(w_1,2*R)),
  23. 'cross2': Line((w_1-R,R), (w_1+R,R))})})
  24. wheel2:
  25. formula: wheel1.copy()
  26. transform: translate((L,0))
  27. under: Rectangle(lower_left_corner=(w_1-2*R, 2*R),
  28. width=2*R + L + 2*R, height=H)
  29. over: Rectangle(lower_left_corner=(w_1, 2*R + H),
  30. width=2.5*R, height=1.25*H)
  31. wheels: |
  32. Composition({'wheel1': wheel1, 'wheel2': wheel2})
  33. body: |
  34. Composition({'under': under, 'over': over})
  35. vehicle: |
  36. Composition({'wheels': wheels, 'body': body})
  37. ground: Wall(x=[R, xmax], y=[0, 0], thickness=-0.3*R)
  38. car: |
  39. Composition({'vehicle': vehicle, 'ground': ground})