-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsacks-spiral.scad
More file actions
145 lines (105 loc) · 3.05 KB
/
sacks-spiral.scad
File metadata and controls
145 lines (105 loc) · 3.05 KB
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
/*
Sacks Spiral
2019-10-01
https://github.com/GeoffMaciolek/????
https://thingiverse.com/whatever (geo profile)
An archimedes spiral highlighting prime numbers. The Sacks Spiral
is based on the Ulam spiral.
https://en.wikipedia.org/wiki/Ulam_spiral
See README.md for details of creating additional
files, such as prime_table.scad etc
*/
/*
Settings
*/
// Base Width - how large do you want this to be, in mm?
// base_width=300;
// Overall Height Ratio - how much of a 'pancake' vs a soda can? 0.1 = Height is 1/10th the width
overall_height_ratio=0.1;
// Max Number - How high do you want to count?
max_num=2500; //scale needs fixing for 'width/num ratio'
include <prime_table.scad>
//primes = [0,1,2,3];
//$fn=160; // Circle face number (can be defined per object)
/*
GLOBALS
*/
base_width=max_num; //*0.173; // Happens to work out this way IF max_num is 300. Fiddling?
overall_height=base_width*overall_height_ratio;
section_height=overall_height/4;
/*
MODULES
*/
module base() {
$fn=160;
cylinder(
h = section_height*2,
r = base_width
);
}
module middle(base_width=200) {
$fn=160;
overall_height=base_width*overall_height_ratio;
translate([0, 0, overall_height])
cylinder(
h = overall_height,
r = base_width*0.8
// y = 0 + overall_height*overall_height_ratio
);
}
module littlespot(x,y,type) { } // TODO
module arch_spiral() {
dia=base_width/60; // to be set up based on max num.
spacing_factor=128;
for(i = [0:max_num]) {
// time = i / 20 * PI;
//x= (4 + (20 * time)) * cos(time);
//y= (4 + (20 * time)) * sin(time);
//x=(-1 * cos(sqrt(i)*2*PI)*sqrt(i))*400;
//y=(sin(sqrt(i)*2*PI)*sqrt(i))*400;
r = sqrt(i);
//echo("I: ", i, " R: ", r);
theta = r * 2 * PI;
x = cos(theta*(180/PI))*(r*spacing_factor);
y = sin(theta*(180/PI))*(r*spacing_factor);
//primeoffset=1
primeoffset= isPrime(i) ? 30 : 0;
//primeoffset=4;
// if it's prime, set above to 2
translate([x,y,overall_height])
cylinder(
r=dia+((primeoffset-1)*1.5), //1.5 here is the 'larger factor' for prime spots
h=section_height//*primeoffset
);
//cube([5,5,5]);
}
/* sachs type:
theta = sqrt(i) * 2 * pi
r = sqrt(i),
and thus its x,y co-ordinates are given by:
x = -cos(sqrt(i)*2*pi)*sqrt(i)
y = sin(sqrt(i)*2*pi)*sqrt(i)
standard:
for i in range(200):
t = i / 20 * pi
x = (1 + 5 * t) * cos(t)
y = (1 + 5 * t) * sin(t)
plot(x, y)
*/
}
function isPrime(num) = (
// Note: "primes" is loaded from prime_table.scad - see for details
search(num,primes) != []
);
/*
BEGIN MAIN EXECUTION
*/
//base();
arch_spiral();
//middle();
/*
// test prime table
for(testy = [1:15]) {
echo(testy, "is prime? ",isPrime(testy));
}
*/