1//////////////////////////////////////////////////////////////////////
2// LibFile: sliders.scad
3// Simple V-groove based sliders and rails.
4// Includes:
5// include <BOSL2/std.scad>
6// include <BOSL2/sliders.scad>
7// FileGroup: Parts
8// FileSummary: Simple sliders and rails.
9//////////////////////////////////////////////////////////////////////
10
11
12// Section: Modules
13
14
15// Module: slider()
16// Description:
17// Creates a slider to match a V-groove rail.
18// Usage:
19// slider(l, w, h, [base=], [wall=], [ang=], [$slop=]) [ATTACHMENTS];
20// Arguments:
21// l = Length (long axis) of slider.
22// w = Width of slider.
23// h = Height of slider.
24// ---
25// base = Height of slider base.
26// wall = Width of wall behind each side of the slider.
27// ang = Overhang angle for slider, to facilitate supportless printig.
28// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
29// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
30// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
31// $slop = The printer-specific slop value to make parts fit just right.
32// Example:
33// slider(l=30, base=10, wall=4, $slop=0.2, spin=90);
34function slider(l=30, w=10, h=10, base=10, wall=5, ang=30, anchor=BOTTOM, spin=0, orient=UP) = no_function("slider");
35module slider(l=30, w=10, h=10, base=10, wall=5, ang=30, anchor=BOTTOM, spin=0, orient=UP)
36{
37 full_width = w + 2*wall;
38 full_height = h + base;
39
40 attachable(anchor,spin,orient, size=[full_width, l, h+2*base]) {
41 zrot(90)
42 down(base+h/2) {
43 // Base
44 cuboid([full_width, l, base-get_slop()], chamfer=2, edges=[FRONT,BACK], except_edges=BOT, anchor=BOTTOM);
45
46 // Wall
47 xflip_copy(offset=w/2+get_slop()) {
48 cuboid([wall, l, full_height], chamfer=2, edges=RIGHT, except_edges=BOT, anchor=BOTTOM+LEFT);
49 }
50
51 // Sliders
52 up(base+h/2) {
53 xflip_copy(offset=w/2+get_slop()+0.02) {
54 bev_h = h/2*tan(ang);
55 prismoid([h, l], [0, l-w], h=bev_h+0.01, orient=LEFT, anchor=BOT);
56 }
57 }
58 }
59 children();
60 }
61}
62
63
64
65// Module: rail()
66// Description:
67// Creates a V-groove rail.
68// Usage:
69// rail(l, w, h, [chamfer=], [ang=]) [ATTACHMENTS];
70// Arguments:
71// l = Length (long axis) of slider.
72// w = Width of slider.
73// h = Height of slider.
74// ---
75// chamfer = Size of chamfer at end of rail.
76// ang = Overhang angle for slider, to facilitate supportless printig.
77// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `BOTTOM`
78// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
79// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
80// Example:
81// rail(l=100, w=10, h=10);
82function rail(l=30, w=10, h=10, chamfer=1.0, ang=30, anchor=BOTTOM, spin=0, orient=UP) = no_function("rail");
83module rail(l=30, w=10, h=10, chamfer=1.0, ang=30, anchor=BOTTOM, spin=0, orient=UP)
84{
85 attack_ang = 30;
86 attack_len = 2;
87
88 fudge = 1.177;
89 chamf = sqrt(2) * chamfer;
90 cosa = cos(ang*fudge);
91 sina = sin(ang*fudge);
92
93 z1 = h/2;
94 z2 = z1 - chamf * cosa;
95 z3 = z1 - attack_len * sin(attack_ang);
96 z4 = 0;
97
98 x1 = w/2;
99 x2 = x1 - chamf * sina;
100 x3 = x1 - chamf;
101 x4 = x1 - attack_len * sin(attack_ang);
102 x5 = x2 - attack_len * sin(attack_ang);
103 x6 = x1 - z1 * sina;
104 x7 = x4 - z1 * sina;
105
106 y1 = l/2;
107 y2 = y1 - attack_len * cos(attack_ang);
108
109 attachable(anchor,spin,orient, size=[w, l, h]) {
110 polyhedron(
111 convexity=4,
112 points=[
113 [-x5, -y1, z3],
114 [ x5, -y1, z3],
115 [ x7, -y1, z4],
116 [ x4, -y1, -z1-0.05],
117 [-x4, -y1, -z1-0.05],
118 [-x7, -y1, z4],
119
120 [-x3, -y2, z1],
121 [ x3, -y2, z1],
122 [ x2, -y2, z2],
123 [ x6, -y2, z4],
124 [ x1, -y2, -z1-0.05],
125 [-x1, -y2, -z1-0.05],
126 [-x6, -y2, z4],
127 [-x2, -y2, z2],
128
129 [ x5, y1, z3],
130 [-x5, y1, z3],
131 [-x7, y1, z4],
132 [-x4, y1, -z1-0.05],
133 [ x4, y1, -z1-0.05],
134 [ x7, y1, z4],
135
136 [ x3, y2, z1],
137 [-x3, y2, z1],
138 [-x2, y2, z2],
139 [-x6, y2, z4],
140 [-x1, y2, -z1-0.05],
141 [ x1, y2, -z1-0.05],
142 [ x6, y2, z4],
143 [ x2, y2, z2],
144 ],
145 faces=[
146 [0, 1, 2],
147 [0, 2, 5],
148 [2, 3, 4],
149 [2, 4, 5],
150
151 [0, 13, 6],
152 [0, 6, 7],
153 [0, 7, 1],
154 [1, 7, 8],
155 [1, 8, 9],
156 [1, 9, 2],
157 [2, 9, 10],
158 [2, 10, 3],
159 [3, 10, 11],
160 [3, 11, 4],
161 [4, 11, 12],
162 [4, 12, 5],
163 [5, 12, 13],
164 [5, 13, 0],
165
166 [14, 15, 16],
167 [14, 16, 19],
168 [16, 17, 18],
169 [16, 18, 19],
170
171 [14, 27, 20],
172 [14, 20, 21],
173 [14, 21, 15],
174 [15, 21, 22],
175 [15, 22, 23],
176 [15, 23, 16],
177 [16, 23, 24],
178 [16, 24, 17],
179 [17, 24, 25],
180 [17, 25, 18],
181 [18, 25, 26],
182 [18, 26, 19],
183 [19, 26, 27],
184 [19, 27, 14],
185
186 [6, 21, 20],
187 [6, 20, 7],
188 [7, 20, 27],
189 [7, 27, 8],
190 [8, 27, 26],
191 [8, 26, 9],
192 [9, 26, 25],
193 [9, 25, 10],
194 [10, 25, 24],
195 [10, 24, 11],
196 [11, 24, 23],
197 [11, 23, 12],
198 [12, 23, 22],
199 [12, 22, 13],
200 [13, 22, 21],
201 [13, 21, 6],
202 ]
203 );
204 children();
205 }
206}
207
208
209
210// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap