nove modely
[mirrors/Designs.git] / openscad / shower_nozzle.scad
1 //sine_thread.scad by Ron Butcher (aka. Ming of Mongo),
2 //with bits borrowed from ISOThread by Trevor Moseley
3 //
4 //Thread libs for OpenSCAD are hideously slow. I love OpenSCAD, but that's the fact.
5 //But I found that, if you are cool with approximating iso threads with a sine wave,
6 //you can make very smooth threads really fast just by spinning a circle around.
7 //
8 //Actually, you could make near perfect threads by specifying a polygon other than a circle
9 //with the exact screw cross-section you need, but I leave that as an excersize for those
10 //who care more than I do. Circle works for me.
11 //
12 //threads module gives a threaded rod
13 //hex_nut(diameter) does just what you think
14 //hex_screw(diameter, length) gives an M(diameter) hex head screw with length mm of thread.
15 //
16 //defaults get you an M4 x 10mm bolt and an M4 nut. If you want something non standard,
17 //you can supply the pitch, head height and diameter, rez(olution) and a scaling factor
18 //to help make up for the oddities of everyone's individual printers and settings.
19 //
20 //Finer layering gets you better results. At .1mm layer height, my M4 threads kick ass.
21 //
22 //This is all metric, but you can translate US diameters and pitch to mm easily enough.
23
24
25 module threads(diameter=4,pitch=undef,length=10,scale=1,rez=20){
26 pitch = (pitch!=undef) ? pitch : get_coarse_pitch(diameter);
27 twist = length/pitch*360;
28 depth=pitch*.6;
29 linear_extrude(height = length, center = false, convexity = 10, twist = -twist, $fn = rez)
30 translate([depth/2, 0, 0]){
31 circle(r = scale*diameter/2-depth/2);
32 }
33 }
34
35 module hex_nut( diameter = 4,
36 height = undef,
37 span = undef,
38 pitch = undef,
39 scale = 1,
40 rez = 20){
41 height = (height!=undef) ? height : hex_nut_hi(diameter);
42 span = (span!=undef) ? span : hex_nut_dia(diameter);
43
44 difference(){
45 cylinder(h=height,r=span/2, $fn=6); //six sided cylinder
46 threads(diameter,pitch,height,scale,rez);
47 cylinder(h=diameter/2, r1=diameter/2, r2=0, $fn=rez);
48 translate([0,0,height+.0001])
49 rotate([180,0,0])
50 #cylinder(h=diameter/2, r1=diameter/2, r2=0, $fn=rez);
51 }
52 }
53
54 module hex_screw(diameter = 4,
55 length = 10,
56 height = undef,
57 span = undef,
58 pitch = undef,
59 scale = 1,
60 rez = 20){
61 height = (height!=undef) ? height : hex_bolt_hi(diameter);
62 span = (span!=undef) ? span : hex_bolt_dia(diameter);
63 cylinder(h=height,r=span/2,$fn=6); //six sided cylinder
64 translate([0,0,height])
65 threads(diameter,pitch,length,scale,rez);
66 }
67
68 // Lookups shamelessly stolen from ISOThread.scad by Trevor Moseley
69 // function for thread pitch
70 function get_coarse_pitch(dia) = lookup(dia, [
71 [1,0.25],[1.2,0.25],[1.4,0.3],[1.6,0.35],[1.8,0.35],[2,0.4],[2.5,0.45],[3,0.5],[3.5,0.6],[4,0.7],[5,0.8],[6,1],[7,1],[8,1.25],[10,1.5],[12,1.75],[14,2],[16,2],[18,2.5],[20,2.5],[22,2.5],[24,3],[27,3],[30,3.5],[33,3.5],[36,4],[39,4],[42,4.5],[45,4.5],[48,5],[52,5],[56,5.5],[60,5.5],[64,6],[78,5]]);
72
73 // function for hex nut diameter from thread size
74 function hex_nut_dia(dia) = lookup(dia, [
75 [3,6.4],[4,8.1],[5,9.2],[6,11.5],[8,16.0],[10,19.6],[12,22.1],[16,27.7],[20,34.6],[24,41.6],[30,53.1],[36,63.5]]);
76 // function for hex nut height from thread size
77 function hex_nut_hi(dia) = lookup(dia, [
78 [3,2.4],[4,3.2],[5,4],[6,3],[8,5],[10,5],[12,10],[16,13],[20,16],[24,19],[30,24],[36,29]]);
79
80
81 // function for hex bolt head diameter from thread size
82 function hex_bolt_dia(dia) = lookup(dia, [
83 [3,6.4],[4,8.1],[5,9.2],[6,11.5],[8,14.0],[10,16],[12,22.1],[16,27.7],[20,34.6],[24,41.6],[30,53.1],[36,63.5]]);
84 // function for hex bolt head height from thread size
85 function hex_bolt_hi(dia) = lookup(dia, [
86 [3,2.4],[4,3.2],[5,4],[6,3.5],[8,4.5],[10,5],[12,10],[16,13],[20,16],[24,19],[30,24],[36,29]]);
87
88 wrench_ratio = 1.1547;
89 wrench = wrench_ratio * 13;
90
91 difference() {
92 union() {
93 //european shower head thread
94 threads(diameter=20, pitch=2, length=10, rez=60);
95 hull() {
96 cylinder(d1=wrench, d2=wrench, h=15, $fn=6);
97 translate([0,0,20]) sphere(d=6, $fn=32);
98 }
99 }
100 translate([0,0,-10]) cylinder(d=1, h=100, $fn=32);
101 translate([0,0,-0.1]) cylinder(d1=4, d2=1, h=10, $fn=32);
102 }
103
104 //translate([18.8,0,0.5])
105 //import("/home/harvie/Downloads/nasadka_na_dysh_2_mm_v1.stl");
This page took 0.303049 seconds and 4 git commands to generate.