threeshapes.scm 948 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. (import (turtle turtle3)
  2. (scheme base))
  3. (define (cube t size)
  4. (repeat (4)
  5. (repeat (4)
  6. (forward! t size)
  7. (yaw! t 90))
  8. (pitch! t 90)
  9. (forward! t size)
  10. (pitch! t -90)
  11. (roll! t -90)))
  12. (define (circle3d t radius)
  13. (define circum (* radius 6.283185307))
  14. (define start-orient (get-orient t))
  15. (define start-pos (get-pos t))
  16. (repeat (120)
  17. (forward! t (/ circum 120))
  18. (pitch! t -3))
  19. (apply set-orient! t start-orient)
  20. (set-pos! t start-pos))
  21. (define (sphere t radius)
  22. (repeat (20)
  23. (circle3d t radius)
  24. (yaw! t 9)))
  25. (define (helix t size)
  26. (repeat (80)
  27. (forward! t (/ size 7))
  28. (yaw! t 10)
  29. (pitch! t 20)))
  30. (define (tetrahedron t size)
  31. (repeat (3)
  32. (repeat (3)
  33. (forward! t size)
  34. (yaw! t 120))
  35. (yaw! t 60)
  36. (roll! t 109.47122063449069)))
  37. (define me (make-turtle))
  38. (nutate! me)
  39. ;(cube me 100)
  40. (sphere me 100)
  41. ;(helix me 100)
  42. ;(tetrahedron me 140)