Transition.scad 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // This openscad script generates a half sphere transition
  2. // between a larger and a smaller pipe
  3. // Resolution of 3D model
  4. $fn=40;
  5. // Thickness of the walls [mm]
  6. wall=3;
  7. /*[ Pipe with larger outer diameter ]*/
  8. // Length of larger pipe without transition [mm]
  9. largePartLen=40;
  10. // Outer diameter of larger pipe [mm]
  11. largePartDia=50.2;
  12. /*[ Pipe with smaller outer diameter ]*/
  13. // Length of smaller pipe without transition [mm]
  14. smallPartLen=20;
  15. // Outer diameter of smaller pipe [mm]
  16. smallPartDia=20.0;
  17. /*[ Hidden ]*/
  18. // Distance between larger and smaller pipe: This is the transition length
  19. //a^2 + b^2 = c^2
  20. //c=r=largePartDia/2
  21. //a=smallPartDia/2
  22. //b=?
  23. //b^2 = c^2 - a^2
  24. // _____________________________________________
  25. //b= V ((largePartDia/2)^2-(smallPartDia/2)^2)
  26. transitionDistance = sqrt((largePartDia/2)^2-(smallPartDia/2)^2);
  27. echo("transitionDistance = ", transitionDistance);
  28. ///////////////////////////////////////////////////////////////////////////////////
  29. // main
  30. ///////////////////////////////////////////////////////////////////////////////////
  31. difference()
  32. {
  33. makeOuterForm();
  34. makeInnerForm();
  35. }
  36. ///////////////////////////////////////////////////////////////////////////////////
  37. // make the outer hull
  38. ///////////////////////////////////////////////////////////////////////////////////
  39. module makeOuterForm()
  40. {
  41. union()
  42. {
  43. // make larger part
  44. translate([0, 0, transitionDistance])
  45. cylinder(h=largePartLen, d=largePartDia);
  46. // make transition between larger and smaller part
  47. translate([0, 0, transitionDistance])
  48. sphere(d=largePartDia);
  49. // make smaller part
  50. translate([0,0,-smallPartLen])
  51. cylinder(h=smallPartLen, d=smallPartDia);
  52. }
  53. }
  54. ///////////////////////////////////////////////////////////////////////////////////
  55. // make the inner hull
  56. ///////////////////////////////////////////////////////////////////////////////////
  57. module makeInnerForm()
  58. {
  59. union()
  60. {
  61. // make larger part
  62. translate([0, 0, transitionDistance])
  63. cylinder(h=largePartLen+wall+0.1, d=largePartDia-2*wall);
  64. // make transition between larger and smaller part
  65. translate([0, 0, transitionDistance])
  66. sphere(d=largePartDia-2*wall);
  67. // make smaller part
  68. translate([0,0,-smallPartLen-0.1])
  69. cylinder(h=smallPartLen+wall+0.2, d=smallPartDia-2*wall);
  70. }
  71. }