-
Notifications
You must be signed in to change notification settings - Fork 0
/
render.scad
58 lines (46 loc) · 1.52 KB
/
render.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
torender = "Whole"; // Valid options include 'Quad', 'Hemi', 'Whole'
radius = 120;
posterior_curvature = 0.5;
anterior_curvature = 0.333;
grooves = 2;
$fs = 1; // set to 1 for fast rendering, 0.05 for rendering to print
// DO NOT CHANGE ANYTHING BELOW THIS LINE
$fa = 1.0;
module mlens() {
difference() {
resize(newsize=[radius, radius, radius * posterior_curvature]) sphere(r=10);
translate([-radius,-radius,0]) cube([radius * 2,radius * 2, radius * 2]);
}
resize(newsize=[radius, radius, radius * anterior_curvature]) sphere(r=10);
}
module lens() {
difference() {
mlens();
if (grooves > 0) {
translate([-0.35 * radius, -radius / 20, -radius * 0.25 * posterior_curvature]) cube([radius * 0.35 * 2, radius / 10, radius * 2]);
}
if (grooves > 1) {
rotate([0,0,90]) translate([-0.35 * radius, -radius / 20, -radius * 0.25 * posterior_curvature]) cube([radius * 0.35 * 2, radius / 10, radius * 2]);
}
}
}
module hemi() {
difference() {
lens();
translate([-2 * radius,-2 * radius, -1 * radius]) cube([2 * radius, 3 * radius, 2 * radius]);
}
}
module quad() {
difference() {
lens();
translate([-2 * radius,-2 * radius, -1 * radius]) cube([2 * radius, 3 * radius, 2 * radius]);
translate([-0.1,0,-1 * radius]) cube([radius * 2, radius * 2,radius * 2]);
}
}
if (torender == "Quad") {
quad();
} else if (torender == "Hemi") {
hemi();
} else if (torender == "Whole") {
lens();
}