No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

util.scad 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2022 - 2023 Thomas Buck (thomas@xythobuz.de)
  3. * Philipp Schönberger (mail@phschoen.de)
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * See <http://www.gnu.org/licenses/>.
  16. */
  17. function sphere_r_at_h(h, r) = r * sin(acos(h / r));
  18. function sphere_angle_at_rh(h, r) = acos(h / r);
  19. module fully_rounded_cube(p,r,center)
  20. {
  21. for(x=[r,p[0]-r],
  22. y=[r,p[1]-r],
  23. z=[r,p[2]-r])
  24. {
  25. translate([x,y,z])
  26. sphere(r,$fn=$fn/4);
  27. }
  28. }
  29. module rounded_cube(x, y, z, r)
  30. {
  31. hull()
  32. for (tx = [r, x - r])
  33. for (ty = [r, y - r])
  34. translate([tx, ty, 0])
  35. cylinder(d = r * 2, h = z);
  36. }
  37. module eps(dir="z")
  38. {
  39. if(dir== "x")
  40. tranlate([-$e,0,0])
  41. children();
  42. if(dir== "y")
  43. translate([0,-$e,0])
  44. children();
  45. if(dir== "z")
  46. translate([0,0,-$e])
  47. children();
  48. }