-
Notifications
You must be signed in to change notification settings - Fork 2
/
scales.scad
208 lines (169 loc) · 4.48 KB
/
scales.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
// Overlapping scales
// X count
_CountX = 10;
// Y count
_CountY = 10;
// X space
_SpaceX = 33;
// Y Space
_SpaceY = 12;
// Alternate spacing on even and odd rows
_EvenOddLayout = true;
// Rotate 180 on odd rows
_EvenOddRotate = false;
// Scale style
_ScaleStyle = "Ring"; // ["Ring", "???"]
/* [Ring-Style Scale] */
// Ring shape
_ScaleRingShape = "Circle"; // ["Circle", "Triangle", "Hexagon", "Octagon"]
// Inner radius of ring
_ScaleRingInnerRadius = 10;
// Outer radius of ring
_ScaleRingOuterRadius = 16;
// Ring thickness
_ScaleRingThickness = 4; // 0.20
// Ring base depth
_ScaleRingBaseDepth = 10;
// Ring vertical stretch
_ScaleRingVerticalStretch = 1.0; // 0.10
// Ring tilt
_ScaleRingTilt = 45;
module _end_config() {}
// Full list of parameters
_Params =
[
["CountX", _CountX],
["CountY", _CountY],
["SpaceX", _SpaceX],
["SpaceY", _SpaceY],
["EvenOddLayout", _EvenOddLayout],
["EvenOddRotate", _EvenOddRotate],
["ScaleStyle", _ScaleStyle],
["ScaleRingShape", _ScaleRingShape],
["ScaleRingTilt", _ScaleRingTilt],
["ScaleRingInnerRadius", _ScaleRingInnerRadius],
["ScaleRingOuterRadius", _ScaleRingOuterRadius],
["ScaleRingBaseDepth", _ScaleRingBaseDepth],
["ScaleRingThickness", _ScaleRingThickness],
["ScaleRingVerticalStretch", _ScaleRingVerticalStretch]
];
// Ring with base
module Ring(Shape, Tilt, InnerRadius, OuterRadius, RingBaseDepth, RingThickness, RingVerticalStretch)
{
// Compute height of leading edge of ring
EdgeHeight = RingThickness * sin(90 - Tilt);
// Compute how far top of leading edge sticks out
EdgeOut = RingThickness * cos(Tilt);
// Map shape to number of sides and rotation
Sides =
(Shape == "Circle") ? 99 :
(Shape == "Triangle") ? 4 :
(Shape == "Hexagon") ? 6 :
(Shape == "Octagon") ? 8 :
0;
if (Sides == 0)
{
echo("Ring: Unknown shape: ", Shape);
}
// Base
translate([0, -EdgeOut, 0])
{
color("green") cube([2 * OuterRadius, RingBaseDepth, EdgeHeight]);
}
// Ring
translate([0, EdgeOut, -EdgeHeight])
{
rotate([Tilt, 0, 0])
{
translate([OuterRadius, 0, RingThickness])
{
linear_extrude(RingThickness)
{
scale([1, RingVerticalStretch, 1])
{
difference()
{
// Matter - Ring
difference()
{
circle(OuterRadius, $fn=Sides);
circle(InnerRadius, $fn=Sides);
}
// Anti-matter - Minus-Y half
translate([-OuterRadius, 2 * -OuterRadius, 0])
{
square(2 * OuterRadius, OuterRadius);
}
}
}
}
}
}
}
}
module OneScaleRing(Shape, Tilt, InnerRadius, OuterRadius, RingBaseDepth, RingThickness, RingVerticalStretch)
{
translate([0, RingThickness, 0])
{
Ring(Shape, Tilt, InnerRadius, OuterRadius, RingBaseDepth, RingThickness, RingVerticalStretch);
}
}
module OneScale(ScaleStyle, Shape, Tilt, InnerRadius, OuterRadius, RingBaseDepth, RingThickness, RingVerticalStretch)
{
if (ScaleStyle == "Ring")
{
OneScaleRing(Shape, Tilt, InnerRadius, OuterRadius, RingBaseDepth, RingThickness, RingVerticalStretch);
}
}
module Panel(CountX, CountY, SpaceX, SpaceY, EvenOddLayout, EvenOddRotate, ScaleStyle, Shape, Tilt, InnerRadius, OuterRadius, RingBaseDepth, RingThickness, RingVerticalStretch)
{
// All the scales
for (x = [0 : CountX - 1])
{
for (y = [0 : CountY - 1])
{
Odd = ((y % 2) == 1);
PointX = EvenOddLayout && Odd ?
(x * SpaceX) + (SpaceX / 2) :
(x * SpaceX);
PointY = y * SpaceY;
translate([PointX, PointY, 0])
{
if (EvenOddRotate && Odd)
{
rotate([0, 0, 180])
{
// FIXME: Y is not quite right
translate([-OuterRadius * 2, -SpaceY, 0])
{
OneScale(ScaleStyle, Shape, Tilt, InnerRadius, OuterRadius, RingBaseDepth, RingThickness, RingVerticalStretch);
}
}
}
else
{
OneScale(ScaleStyle, Shape, Tilt, InnerRadius, OuterRadius, RingBaseDepth, RingThickness, RingVerticalStretch);
}
}
}
}
}
// Generate a legend to capture all of the parameters
module Legend(Items)
{
for (i = [0 : len(Items) - 1])
{
Item = Items[i];
echo(Item[0], "=", Item[1]);
}
}
module main()
{
intersection()
{
Panel(_CountX, _CountY, _SpaceX, _SpaceY, _EvenOddLayout, _EvenOddRotate, _ScaleStyle, _ScaleRingShape,_ScaleRingTilt, _ScaleRingInnerRadius, _ScaleRingOuterRadius, _ScaleRingBaseDepth, _ScaleRingThickness, _ScaleRingVerticalStretch);
cube([1000, 1000, 100]);
}
Legend(_Params);
}
main();