Advertisement
Guest User

pod.scad

a guest
Jan 21st, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. module toc(r, l, rn=0) {
  2. rho = (pow(r, 2) + pow(l, 2)) / (2 * r);
  3. xo = l - sqrt(pow(rho - rn, 2)-pow(rho - r, 2));
  4. yt = (rn * (rho - r)) / (rho - rn);
  5. xt = xo - sqrt(pow(rn, 2) - pow(yt, 2));
  6.  
  7. rotate_extrude(convexity=10, $fn=128) {
  8. union() {
  9. translate([0, l - xo ,0])
  10. intersection() {
  11. circle(r=rn, $fn=256);
  12. square(rn);
  13. }
  14. intersection() {
  15. translate([-rho + r, 0, 0]) circle(r=rho, $fn=256);
  16. square([r, l - xt]);
  17. }
  18. }
  19. }
  20. }
  21.  
  22. module body_back(w, h, l) {
  23. rotate([-90, 0, 0]) resize([w, h, l]) difference() {
  24. toc(w / 2, l);
  25. translate([-w / 2, 0, -1]) cube([w, w / 2, l + 1]);
  26. }
  27. }
  28.  
  29. module body_front(w, h, l) {
  30. resize([w, l, h]) difference() {
  31. sphere(w / 2);
  32. translate([-w / 2, 0, -w / 2]) cube([w, w / 2, w]);
  33. translate([-w / 2, -w / 2, -w / 2]) cube([w, w / 2, w / 2]);
  34. }
  35. }
  36.  
  37. module body_block(w, h, l, front_part=0.3) {
  38. body_front(w, h, l * front_part);
  39. body_back(w, h, l * (1 - front_part));
  40. }
  41.  
  42. module body(w, h, l, th, front_part=0.3, cut_angle=45, cut_ratio=0.2) {
  43. cut_h = h - (h * cut_ratio);
  44. a = h * cut_ratio * sin(90 - cut_angle) / sin(cut_angle);
  45. difference() {
  46. difference() {
  47. body_block(w, h, l, front_part);
  48. body_block(w - th, h - th, l - th, front_part);
  49. }
  50.  
  51. polyhedron([[w / 2, 0, cut_h],
  52. [w / 2, l, cut_h],
  53. [-w / 2, l, cut_h],
  54. [-w / 2, 0, cut_h],
  55. [w / 2, -a, h],
  56. [w / 2, l, h],
  57. [-w / 2, l, h],
  58. [-w / 2, -a, h]],
  59. [[0, 1, 2, 3],
  60. [4, 5, 1, 0],
  61. [5, 6, 2, 1],
  62. [6, 7, 3, 2],
  63. [7, 4, 0, 3],
  64. [7, 6, 5, 4]]);
  65. }
  66. }
  67.  
  68. $fn=128;
  69.  
  70. body(1000, 700, 2000, 10);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement