-
Notifications
You must be signed in to change notification settings - Fork 18
/
hirth-joint.scad
172 lines (147 loc) · 5.37 KB
/
hirth-joint.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*
* Copyright (c) 2019, Gilles Bouissac
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* Description: Hirth Joint modelisation
* Author: Gilles Bouissac
*/
use <list-comprehension-demos/skin.scad>
use <scad-utils/lists.scad>
use <agentscad/printing.scad>
// Demo: See test-hirth-joint.scad
// ----------------------------------------
// API
// ----------------------------------------
// rmax: Radius of external cylinder containing teeth
// teeth: Nunber of required teeth
// height: Teeth height
// shoulder: Shoulder height (base cylinder below teeth)
// inlay: Inlay height (hexagonal inlay below shoulder)
// shift: Number of tooth to rotate the resuting teeth set
// Hirth Joint with sinusoidal profile
module hirthJointSinus ( rmax, teeth, height, shoulder=0, inlay=0, shift=0, rmin=undef ) {
alpha = atan( (height/2)/rmax );
th = (rmax*tan(2*alpha)/cos(alpha));
width = 2*PI*rmax/teeth;
hirthJoint ( hirthJointProfileSinus(teeth), rmax, teeth, height, shoulder, inlay, shift, rmin );
}
// Hirth Joint with triangular profile
module hirthJointTriangle ( rmax, teeth, height, shoulder=0, inlay=0, shift=0, rmin=undef ) {
alpha = atan( (height/2)/rmax );
th = (rmax*tan(2*alpha)/cos(alpha));
width = 2*PI*rmax/teeth;
hirthJoint ( hirthJointProfileTriangle(), rmax, teeth, height, shoulder, inlay, shift, rmin );
}
// Hirth Joint with rectangular profile
module hirthJointRectangle ( rmax, teeth, height, shoulder=0, inlay=0, shift=0, rmin=undef ) {
alpha = atan( (height/2)/rmax );
th = (rmax*tan(2*alpha)/cos(alpha));
width = 2*PI*rmax/teeth;
hirthJoint ( hirthJointProfileRectangle(), rmax, teeth, height, shoulder, inlay, shift, rmin );
}
module hirthJointPassage ( rmax, height, shoulder=0, inlay=0 ) {
height = inlay+height+shoulder;
translate( [0,0,-inlay] )
cylinder( r=rmax/cos(30)+gap()/2, h=height, $fn=6 );
}
// ----------------------------------------
// Implementation
// ----------------------------------------.
NB_MIN_NOZZLE = 3; // Minimal nb nozzle pass for a tooth width
module hirthJoint ( profile, rmax, teeth, height, shoulder=0, inlay=0, shift=0, rmin=undef ) {
_rmin = is_undef(rmin) ? NB_MIN_NOZZLE*nozzle()*teeth/(2*PI) : rmin ;
angle = 360/teeth;
prf = is_undef(profile) ? hirthJointProfileSinus(teeth) : profile;
translate( [0,0,+shoulder] )
difference () {
step=360/teeth;
rotate ([0,0,shift*step])
for ( a=[0:step:360] )
rotate( [0,0,a] )
hirthJointTooth( prf, teeth, rmax, angle, height );
translate( [0,0,+height/2] )
cylinder( r=_rmin, h=10*height, center=true );
}
if ( shoulder>0 ) {
translate( [0,0,+shoulder/2] )
difference () {
cylinder( r=rmax, h=shoulder, center=true );
cylinder( r=_rmin, h=10*shoulder, center=true );
}
}
if ( inlay>0 ) {
translate( [0,0,-inlay/2] )
cylinder( r=rmax/cos(30), h=inlay, center=true, $fn=6 );
}
}
// Profile job is to give a list at least 3 points with these constraints:
// x: in range [-1,1]
// y: in range [0,1], y=0 is the base of the joint
function hirthJointProfileSinus(teeth=1) =
let (
required_step = $fn>0?teeth*360/$fn:180,
step = required_step>18?18:required_step
)[
for ( a=[-180:step:180] )
[a/180,1/2*cos(a)+1/2]
];
function hirthJointProfileTriangle() = [
[-1, 0],
[0, 1],
[1, 0],
];
function hirthJointProfileRectangle() = [
[-1,0],
[-1/2+gap()/2,0],
[-1/2+gap()/2,1],
[+1/2-gap()/2,1],
[+1/2-gap()/2,0],
[+1,0],
];
module hirthJointTooth ( profile, teeth, radius, angle, height ) {
// The profile must be enought subdivided
max_dist = (2*PI/$fn)*radius;
local_profile = [ for (i = [0:len(profile)-1])
if ( i==(len(profile)-1) )
profile[i]
else
let(
dist = profile[i+1].x-profile[i].x,
subdiv = ceil(dist/max_dist) > 1 ? ceil(dist/max_dist):1
)
for (p = interpolate(profile[i],profile[i+1],subdiv))
p
];
points = concat (
flatten([ for ( pr=local_profile )
let (
a = pr.x*angle/2
)[
[ radius*cos(a), radius*sin(a), height*pr.y ],
[ radius*cos(a), radius*sin(a), 0 ],
]
]),
[
[ 0, 0, height/2 ],
[ 0, 0, 0 ]
]
);
o1 = len(points)-2;
o2 = len(points)-1;
faces = concat (
flatten([ for ( i=[0:len(local_profile)-2] )
[
[ 2*i+1, 2*i+0, 2*i+2, 2*i+3 ],
[ 2*i+2, 2*i+0, o1 ],
[ 2*i+1, 2*i+3, o2 ]
]
]),
[ [ 0, 1, o2, o1 ] ],
[ [ 2*(len(local_profile)-1)+1, 2*(len(local_profile)-1)+0, o1, o2 ] ]
);
polyhedron(points,faces,convexity=10);
}