-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo-and-algorithm-outline.scad
162 lines (141 loc) · 4.33 KB
/
demo-and-algorithm-outline.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
//$t=0.5;
effectorPivots = [[ 220.0, -140.0, 130.0],
[-220.0, -140.0, 130.0],
[ 230.0, -130.0, 130.0],
[ 5.0, 270.0, 130.0],
[ -5.0, 270.0, 130.0],
[-230.0, -130.0, 130.0]];
anchorPivots=[[ 220.00, -1744.54, 15.92],
[ -220.00, -1744.54, 15.92],
[ 1542.51, 1140.88, -32.19],
[ 1317.51, 1540.88, -32.19],
[-1435.30, 1011.60, -31.23],
[-1670.30, 611.63, -31.23]];
// A bounding box of big x big x big
// fully encloses the centered model
big = 10000;
//for (effectorPivot = effectorPivots)
// translate(effectorPivot) color("red") sphere(30);
//for (anchorPivot = anchorPivots)
// translate(anchorPivot) color("blue") sphere(30);
//translate([610, 0, 0]) color("yellow") cylinder(r=40, h=t);
//translate([610, 45, 0]) color("purple") cylinder(r=40, h=t + 130);
module twistVase() {
linear_extrude(height=1000, twist=1.3*360)
for (i = [0:360/5:359])
rotate([0,0,i])
translate([100, 0, 0]) circle(r=100);
}
module fourPoles() {
width = 300;
translate([width/2-2, width/2-2, 0]) cube([2,2,1000]);
translate([-width/2, -width/2, 0]) cube([2,2,1000]);
translate([-width/2, width/2-2, 0]) cube([2,2,1000]);
translate([width/2-2, -width/2, 0]) cube([2,2,1000]);
}
//!benchy();
module benchy() {
// Grått
color("#e6e6e2")
scale(20)
import("./linc/linc/test-models/benchy-low-poly.binary.stl", convexity=4);
}
module theModel() {
//cylinder(d=600, h=1200);
//side = 480;
//translate([-side/2, -side/2, 0]) cube(side);
//twistVase();
//fourPoles();
benchy();
}
module theModelPartial(h) {
intersection()
{
theModel();
// green
color("#41790f", 0.30)
translate([-big/2, -big/2, -big + h + 0.3]) cube(big);
}
// For some reason, the difference() method doesn't preview right
//difference(){
// theModel();
// translate([-big/2, -big/2, h]) cube(big);
//}
}
module volumeEnclosedByLineMovements(h) {
// mirror([0,1,0])
for (i = [0:1:len(effectorPivots) - 1])
hull() {
translate(effectorPivots[i]) {
// A slice of the model that is to be printed right now
intersection()
{
translate([-big/2, -big/2, h]) cube([big, big, 1]);
theModel();
}
//difference() {
// theModel();
// translate([-big/2, -big/2, t+2]) cube(big);
// translate([-big/2, -big/2, -big+t]) cube(big);
//}
}
translate(anchorPivots[i]) cube(1, center=true);
}
}
//$t = 1;
t = $t*980;
// rotate
$vpr = [80, 0, $t * 270 - 45];
// no rotate
//$vpr = [75, 0, 0];
$vpt = [0,0,410];
$vpd = 3000;
theSimulation();
module theSimulation() {
difference(){
theModelPartial(t);
color("#DE5643") {
intersection()
{
theModelPartial(t);
volumeEnclosedByLineMovements(t);
}
}
// Would be nice to show which parts were cut away
// from previous layers like this, but unfortunately
// this code crashes my Openscad 2018.04.19
//for (k = [0:200:t])
//{
// intersection()
// {
// theModelPartial(k);
// volumeEnclosedByLineMovements(k);
// }
//}
}
color("#FEEF66")
scale(1.05)
intersection()
{
theModelPartial(t);
volumeEnclosedByLineMovements(t);
}
//theModelPartial(t);
//color("deepskyblue", 0.2)
//volumeEnclosedByLineMovements(t);
}
// To make a gif out of this, run in animation mode and dump pictures
// I'm sure that could be done on the command line, but hard to find
// good values for $vpr, $vpt, and $vpd via command line.
// Once you have the frames, create a pallette:
// $ ffmpeg -i frames/frame%05d.png -vf palettegen frames/palette.png
// Once you have frames and pallete, create gif:
// $ ffmpeg -v warning -framerate 200 -i frames/frame%05d.png -i frames/palette.png -lavfi "paletteuse,setpts=6*PTS" -y out.gif
// To swap out some colors in all the images:
// mkdir fixed_colors
// for ((i=0; i<=599; i++)); do
// num=$(printf "%05d" $i);
// convert "frame${num}.png" -transparent "#aaaaff" -fuzz 5% -fill "#41790f" -opaque "#8897b7" "fixed_colors/frame${num}.png";
// done
// To resize all the images:
// for ((i=0; i<=599; i++)); do num=$(printf "%05d" $i); convert "frame${num}.png" -resize 500 small/frame${num}.png; done