Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. # ANEX-SPEC: 1
  2. # ANEX-ID: astronouth7303@gmail.com/fillet-90-straight
  3. # ANEX-VERSION: 1.0
  4. # ANEX-AUTHOR: Jamie Bliss <astronouth7303@gmail.com>
  5. # ANEX-CATEGORY: Routing
  6. # ANEX-TAGS: routing, fillet
  7. # ANEX-DESC: A 90deg straight-line fillet primitve suitable for union or subtraction
  8. """
  9. A primitive for fillets. Union for interior corners; subtract with exterior ones.
  10.  
  11. Runs the fillet from (`x0`, `y0`, `z0`) to (`x1`, `y1`, `z1`) with radius `r`.
  12.  
  13. `a` is the angle of the rotation of the fillet. Sorry, there's no easy way to describe it.
  14. """
  15. import math
  16. import fab
  17.  
  18. title('Fillet (Straight, 90)')
  19.  
  20. input('x0', float)
  21. input('y0', float)
  22. input('z0', float)
  23.  
  24. input('x1', float)
  25. input('y1', float)
  26. input('z1', float)
  27.  
  28. input('r', float)
  29. input('a', float)
  30.  
  31. length = math.sqrt((x1-x0)**2 + (y1-y0)**2 + (z1-z0)**2)
  32. theta = math.atan2(y1-y0, x1-x0)*180/math.pi
  33. phi = math.acos((z1-z0)/length)*180/math.pi
  34.  
  35. #output('length', length)
  36. #output('theta', theta)
  37. #output('phi', phi)
  38.  
  39. tri = fab.shapes.triangle(r, 0, 0, r, r, r)
  40. circle = fab.shapes.circle(0, 0, r)
  41.  
  42. flat = tri & ~circle
  43.  
  44. flat = fab.shapes.origin_xy(flat, r, r, 0, 0)
  45.  
  46. #flat = fab.shapes.iterate_polar(flat, 0, 0, 4)
  47.  
  48. fillet = fab.shapes.extrude_z(flat, 0, length)
  49. fillet = fab.shapes.rotate_z(fillet, a, 0, 0)
  50. fillet = fab.shapes.rotate_y(fillet, -phi, 0, 0)
  51. fillet = fab.shapes.rotate_z(fillet, theta, 0, 0)
  52. fillet = fab.shapes.translate(fillet, x0, y0, z0)
  53. output('shape', fillet)
  54.  
  55. # UI
  56. fab.ui.point(x0, y0, z0)
  57. fab.ui.point(x1, y1, z1)
  58. fab.ui.wireframe([(x0, y0, z0), (x1, y1, z1)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement