Guest User

Untitled

a guest
Feb 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. module multiHull(){
  2. for (i = [1 : $children-1])
  3. hull(){
  4. children(0);
  5. children(i);
  6. }
  7. }
  8.  
  9. module sequentialHull(){
  10. for (i = [0: $children-2])
  11. hull(){
  12. children(i);
  13. children(i+1);
  14. }
  15. }
  16.  
  17. /* Extended fun hull functions */
  18.  
  19. module cylinders(points, diameter, thickness){
  20. for (p=points){
  21. translate(p) cylinder(d=diameter, h=thickness, center=true);
  22. }
  23. }
  24.  
  25. module plate(points, diameter, thickness, hole_diameter){
  26. difference(){
  27. hull() cylinders(points, diameter, thickness);
  28. cylinders(points, hole_diameter, 1000);
  29. }
  30. }
  31.  
  32. module bar(length, width, thickness, hole_diameter){
  33. plate([[0,0,0], [length,0,0]], width, thickness, hole_diameter);
  34. }
  35.  
  36. module rounded_box(points, radius, height){
  37. hull(){
  38. for (p = points){
  39. translate(p)
  40. cylinder(r=radius, h=height);
  41. }
  42. }
  43. }
  44.  
  45. module point_cloud(points, radius=1, facets=8){
  46. for (p=points){
  47. translate(p)
  48. sphere(radius/cos(180/facets), $fn=facets);
  49. // polygon sphere circumscribed on radius
  50. }
  51. }
  52.  
  53. module point_hull(points, radius=1, facets=8){
  54. hull(){
  55. point_cloud(points, radius, facets);
  56. }
  57. }
  58.  
  59. // Shrink the exterior of the points so that the hull fits inside
  60. function select(vector, i) = [ for (p=vector) p[i] ];
  61. function axis_center(v, i) = (max(select(v, i)) - min(select(v,i)))/2;
  62. function center(v) = [ for (i = [0,1,2]) axis_center(v, i) ];
  63. function shrink_point(point, center, radius) = [ for (i = [0,1,2]) point[i] > center[i] ? point[i] - radius : point[i] + radius ];
  64. function shrink(points, radius) = [ for (p = points) shrink_point(p, center(points), radius) ];
  65.  
  66. module interior_point_hull(points, radius=1){
  67. point_hull(shrink(points, radius), radius);
  68. }
  69.  
  70. module interior_rounded_box(points, radius, height){
  71. rounded_box(shrink(points, radius), radius, height);
  72. }
  73.  
  74.  
  75. module mirror_copy(v = [1, 0, 0]) {
  76. children();
  77. mirror(v) children();
  78. }
Add Comment
Please, Sign In to add comment