-
Notifications
You must be signed in to change notification settings - Fork 0
/
chaos_toy.scad
124 lines (95 loc) · 3.68 KB
/
chaos_toy.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
// chaos_toy.scad
// Chaos Toy part library by W. Craig Trader is dual-licensed under
// Creative Commons Attribution-ShareAlike 3.0 Unported License and
// GNU Lesser GPL 3.0 or later.
include <MCAD/units.scad>
// ----- Measurements ---------------------------------------------------------
rch = 1 / 128 * inch;
BALL_OD = 92 * rch;
JACK_BASE = 22 * mm; // 111 * rch;
JACK_SPAR_LEN = 25 * mm; // 126 * rch; // 25 * mm;
JACK_SPAR_WID = 15.5 * mm; // 78 * rch;
JACK_SPAR_DEP = 1.75 * mm; // 9 * rch;
JACK_SIZE = JACK_SPAR_LEN + JACK_BASE + JACK_SPAR_LEN;
TUBE_ID = 78.5 * rch;
TUBE_OD = 96.5 * rch;
TUBE_SMALL = 15 * cm;
TUBE_MEDIUM = TUBE_SMALL + JACK_BASE + TUBE_SMALL;
TUBE_LONG = TUBE_MEDIUM + JACK_BASE + TUBE_SMALL;
CONNECTOR_LENGTH = 39 * rch;
TRACK_RAIL_WIDTH = 25 * rch;
TRACK_RAIL_HEIGHT = 34 * rch;
TRACK_RAIL_SPACING = 96 * rch;
TRACK_BASE_HEIGHT = 26 * rch;
TRACK_BASE_WIDTH = 49 * rch;
TRACK_BASE_ID = 22 * rch;
TRACK_SHORT_LENGTH = 4.5 * inch;
TRACK_LONG_LENGTH = 2 * TRACK_SHORT_LENGTH;
// ----- Measurement Checks ---------------------------------------------------
function inches( d ) =
str( floor( d/inch ), "+", floor( 128 * ( d/inch - floor( d/inch ) ) ), "/128 in." );
function verbose_measurement( label, dimension ) =
str( label, " = ", dimension, "mm or ", inches( dimension ) );
module echo_all_measurements() {
echo( verbose_measurement( "Ball diameter", BALL_OD ) );
echo( verbose_measurement( "Tube inside diameter", TUBE_ID ) );
echo( verbose_measurement( "Tube outside diameter", TUBE_OD ) );
echo( verbose_measurement( "Small tube length", TUBE_SMALL ) );
echo( verbose_measurement( "Medium tube length", TUBE_MEDIUM ) );
echo( verbose_measurement( "Long tube length", TUBE_LONG ) );
echo( verbose_measurement( "Jack base", JACK_BASE ) );
echo( verbose_measurement( "Jack spar length", JACK_SPAR_LEN ) );
echo( verbose_measurement( "Jack spar width", JACK_SPAR_WID ) );
echo( verbose_measurement( "Jack spar depth", JACK_SPAR_DEP ) );
echo( verbose_measurement( "Jack size", JACK_SIZE ) );
}
// echo_all_measurements();
// ----- Ball -----------------------------------------------------------------
module ball () {
color( [1,1,0,1] )
sphere( r=BALL_DIAMETER );
}
// ----- Tubes ----------------------------------------------------------------
module tube( length ) {
color( [0,0,1,1] )
difference() {
cylinder( h=length, r=TUBE_OD/2, center=true, $fn=90 );
cylinder( h=length+2*mm, r=TUBE_ID/2, center=true, $fn=90 );
}
}
// ----- Jacks ----------------------------------------------------------------
module jack_spar() {
x = JACK_SIZE / 2;
y = JACK_SPAR_WID / 2;
difference() {
cube( [ JACK_SIZE, JACK_SPAR_WID, JACK_SPAR_DEP ], true );
translate( [+x,+y,0] ) rotate( [0,0,45] ) cube( 4*mm, true );
translate( [+x,-y,0] ) rotate( [0,0,45] ) cube( 4*mm, true );
translate( [-x,+y,0] ) rotate( [0,0,45] ) cube( 4*mm, true );
translate( [-x,-y,0] ) rotate( [0,0,45] ) cube( 4*mm, true );
}
}
module jack() {
color( [0,0,0,1] )
union() {
jack_spar();
rotate( [00,00,90] ) jack_spar();
rotate( [00,90,00] ) jack_spar();
rotate( [00,90,90] ) jack_spar();
rotate( [90,00,00] ) jack_spar();
rotate( [90,00,90] ) jack_spar();
cube( JACK_BASE, center=true );
}
}
// ----- Straight Track -------------------------------------------------------
module track_base( length ) {
offset = -1 * mm;
difference() {
cube( [ length, TRACK_BASE_WIDTH, TRACK_BASE_HEIGHT ], true );
translate( [0, 0, offset ] ) rotate( [ 0, 90, 0 ] )
cylinder( h=length+2*mm, r=TRACK_BASE_ID/2, center=true, $fn=45 );
translate( [0, 0, -TRACK_BASE_ID/2+offset ] )
cube( [ length+2*mm, TRACK_BASE_ID, TRACK_BASE_ID ], center=true );
}
}
track_base( TRACK_SHORT_LENGTH );