-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.scad
71 lines (63 loc) · 2.26 KB
/
common.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
// Font information
use <font/dist/xwing-miniatures.ttf>
XWING_FONT = "x\\-wing\\-symbols:style=wing\\-symbols";
// Increase resolution on circles
$fn = 120;
// Dimension constants
TOKEN_THICKNESS = 2.25;
WELL_DEPTH = 1.2;
WELL_RIM = 0.8;
TOLERANCE = 0.05;
// Module to create a token base given the 2D outline
module token_base() {
difference() {
linear_extrude(TOKEN_THICKNESS) {
children();
}
translate([0, 0, TOKEN_THICKNESS - WELL_DEPTH]) {
linear_extrude(WELL_DEPTH + TOLERANCE) {
offset(delta=-WELL_RIM) {
children();
}
}
}
}
}
// Module to create the token symbol given the 2D outline
module token_symbol() {
translate([0, 0, TOKEN_THICKNESS - WELL_DEPTH]) {
linear_extrude(WELL_DEPTH) {
children();
}
}
}
// Module to create 2D guide nubs along the X axis
NUB_WIDTH = 3.75;
NUB_HEIGHT = 3.25;
NUB_RADIUS = NUB_WIDTH / 2;
NUB_SPACING = 22;
NUB_SPACING_HALF = NUB_SPACING / 2;
module guide_nubs() {
polygon([
[NUB_SPACING_HALF + NUB_WIDTH, NUB_HEIGHT],
[NUB_SPACING_HALF + NUB_WIDTH, -(NUB_HEIGHT - NUB_RADIUS)],
[NUB_SPACING_HALF, -(NUB_HEIGHT - NUB_RADIUS)],
[NUB_SPACING_HALF, 0],
[-(NUB_SPACING_HALF), 0],
[-(NUB_SPACING_HALF), -(NUB_HEIGHT - NUB_RADIUS)],
[-(NUB_SPACING_HALF + NUB_WIDTH), -(NUB_HEIGHT - NUB_RADIUS)],
[-(NUB_SPACING_HALF + NUB_WIDTH), NUB_HEIGHT]
]);
translate([NUB_SPACING_HALF + NUB_RADIUS, -(NUB_HEIGHT - NUB_RADIUS)]) {
circle(r=NUB_RADIUS);
}
translate([-(NUB_SPACING_HALF + NUB_RADIUS), -(NUB_HEIGHT - NUB_RADIUS)]) {
circle(r=NUB_RADIUS);
}
}
// Function to determine a point on a circle (for use in calls to polygon())
function point_on_circle(angle, r) = [cos(angle) * r, sin(angle) * r];
// Function to determine the central angle a chord of a circle sweeps out
function angle_of_chord(r, l) = 2 * asin(l / (2 * r));
// Function to determine a new point that is a set distance and angle from an existing point
function point_at_angle(point, angle, dist) = point + point_on_circle(angle, dist);