-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrigami_PrismaticJoint_CreasePattern.m
441 lines (322 loc) · 12.6 KB
/
Origami_PrismaticJoint_CreasePattern.m
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
% Graph for crease pattern - Origami prismatic joint
% Last edited 6/15/2021 by Lucien Peach
function [dataFoldE, m, lmax] = Origami_PrismaticJoint_CreasePattern(r, n, nl, ls, l1, l2, h0, h1, h2, alpha, beta)
% Counter used for data structure indexing
count = 1;
% Identify colors
orange = [1, 0.41, 0];
blue = [0, 0, 1];
black = [0, 0, 0];
red = [1, 0, 0];
% Begin by defining boundaries of sheet
% -------------------------------------------------------------------
% This sheet boundary is irregular in that a small section on the right
% hand side is left blank, as it will be populated by the vertical fold
% region
% Overall boundary
boundarybottom = [0, 0; n*ls, 0];
boundaryleft = [0, 0; 0, h1 + 2*l2 + nl*2*l1 + h2 + l2];
boundarytop = [0, h1 + 2*l2 + nl*2*l1 + h2 + l2; n*ls, h1 + 2*l2 + nl*2*l1 + h2 + l2];
boundaryright = [n*ls, h1 + 2*l2 + nl*2*l1 + h2 + l2; n*ls, 0];
%[(n+1)*ls, h1 + 2*l2; (n+1)*ls, 0; 0, 0; 0, h1 + 2*l2 + nl*2*l1 + h2; ...
% (n+1)*ls, h1 + 2*l2 + nl*2*l1 + h2; (n+1)*ls, h1 + 2*l2 + nl*2*l1];
% Log data to structure and add to plot
dataFoldE(count).x = boundarybottom(:, 1);
dataFoldE(count).y = boundarybottom(:, 2);
dataFoldE(count).color = black;
figure()
plot(dataFoldE(count).x, dataFoldE(count).y, 'color', ...
dataFoldE(count).color)
hold on
set(gcf, 'color', 'w')
% Increase count
count = count + 1;
% Log data to structure and add to plot
dataFoldE(count).x = boundaryleft(:, 1);
dataFoldE(count).y = boundaryleft(:, 2);
dataFoldE(count).color = black;
plot(dataFoldE(count).x, dataFoldE(count).y, 'color', ...
dataFoldE(count).color)
% Increase count
count = count + 1;
% Log data to structure and add to plot
dataFoldE(count).x = boundarytop(:, 1);
dataFoldE(count).y = boundarytop(:, 2);
dataFoldE(count).color = black;
plot(dataFoldE(count).x, dataFoldE(count).y, 'color', ...
dataFoldE(count).color)
% Increase count
count = count + 1;
% Log data to structure and add to plot
dataFoldE(count).x = boundaryright(:, 1);
dataFoldE(count).y = boundaryright(:, 2);
dataFoldE(count).color = black;
plot(dataFoldE(count).x, dataFoldE(count).y, 'color', ...
dataFoldE(count).color)
% Increase count
count = count + 1;
% Log data to structure and add to plot
dataFoldE(count).x = boundaryleft(:, 1);
dataFoldE(count).y = boundaryleft(:, 2);
dataFoldE(count).color = blue;
plot(dataFoldE(count).x, dataFoldE(count).y, 'color', ...
dataFoldE(count).color)
% Increase count
count = count + 1;
% Log data to structure and add to plot
dataFoldE(count).x = boundaryright(:, 1);
dataFoldE(count).y = boundaryright(:, 2);
dataFoldE(count).color = blue;
plot(dataFoldE(count).x, dataFoldE(count).y, 'color', ...
dataFoldE(count).color)
% Increase count
% count = count + 1;
% Specify proximal line
% ------------------------------------------------------------------
% Store proximal line coordinates to array
% proximalx = [0; n*ls];
% proximaly = [h1; h1];
% dataFoldE(count).x = proximalx;
% dataFoldE(count).y = proximaly;
% dataFoldE(count).color = red;
% Plot proximal line
% plot(dataFoldE(count).x, dataFoldE(count).y, 'color', ...
% dataFoldE(count).color);
% The distal line will be overwritten by the top of the folded section, so
% we can ignore it for this purpose.
% Specify boundaries of folded section
% ------------------------------------------------------------------
% Increase counter
count = count + 1;
% Store top horizontal fold lines to array
foldtopx = [0; n*ls];
foldtopy = [h1 + 2*l2 + nl*2*l1; h1 + 2*l2 + nl*2*l1];
dataFoldE(count).x = foldtopx;
dataFoldE(count).y = foldtopy;
dataFoldE(count).color = orange;
% Plot top boundary
plot(dataFoldE(count).x, dataFoldE(count).y, 'color', ...
dataFoldE(count).color)
% Increase counter
count = count + 1;
% Store bottom horizontal fold lines to array
foldbottomx = [0; n*ls];
foldbottomy = [h1 + 2*l2; h1 + 2*l2];
dataFoldE(count).x = foldbottomx;
dataFoldE(count).y = foldbottomy;
dataFoldE(count).color = orange;
% Plot bottom boundary of midsection
plot(dataFoldE(count).x, dataFoldE(count).y, 'color', ...
dataFoldE(count).color)
% Specify intermediary horizontal lines for nl > 1
% ------------------------------------------------------------------
if nl > 1
% Initialization of horizontal lines vector
orange_horizon = zeros(2*(nl-1), 2);
for i = 2:2:(nl*2)-2
% Increase count initially
count = count + 1;
% Populate x and y values for each horizontal line
orange_horizon(i-1, 1) = 0;
orange_horizon(i-1, 2) = h1 + 2*l2 + (i/2)*2*l1;
orange_horizon(i, 1) = n*ls;
orange_horizon(i, 2) = h1 + 2*l2 + (i/2)*2*l1;
% Store to array
dataFoldE(count).x = orange_horizon(i-1:i, 1);
dataFoldE(count).y = orange_horizon(i-1:i, 2);
dataFoldE(count).color = orange;
% Plot each line
plot(dataFoldE(count).x, dataFoldE(count).y, 'color', ...
dataFoldE(count).color);
end
end
% Specify horizontal line at l2:l2 boundary
% ------------------------------------------------------------------
% Increase counter
count = count + 1;
% Store x and y coordinates to array
lowerboundaryx = [0; n*ls];
lowerboundaryy = [h1 + l2; h1 + l2];
dataFoldE(count).x = lowerboundaryx;
dataFoldE(count).y = lowerboundaryy;
dataFoldE(count).color = blue;
% Begin plot. Plot line
plot(dataFoldE(count).x, dataFoldE(count).y, 'color', ...
dataFoldE(count).color);
% Specify vertical line pattern for non-folded region (blue lines)
% ------------------------------------------------------------------
% Bottom tube folds and graphing
bottomtube = zeros(2*(n-1), 2);
% Ignore side coordinates as these are graphed by the boundary section
for ii = 1:2:2*(n-1)
% Increase count initially
count = count + 1;
% Indexing
index = ((ii-1)/2) + 1;
% Populate array
bottomtube(ii, 1) = index*ls;
bottomtube(ii, 2) = 0;
bottomtube(ii+1, 1) = index*ls;
bottomtube(ii+1, 2) = h1 + 2*l2;
% Log data to structure and add to plot. Plotting is sequential
dataFoldE(count).x = bottomtube(ii:ii+1, 1);
dataFoldE(count).y = bottomtube(ii:ii+1, 2);
dataFoldE(count).color = blue;
plot(dataFoldE(count).x, dataFoldE(count).y, 'color', ...
dataFoldE(count).color)
end
% Top tube folds and graphing
toptube = zeros(2*(n-1), 2);
% Ignore side folds as these are graphed by the boundary section
for jj = 1:2:2*(n-1)
% Increase count initially
count = count + 1;
% Indexing
index = ((jj-1)/2) + 1;
% Populate array
toptube(jj, 1) = index*ls;
toptube(jj, 2) = h1 + 2*l2 + nl*2*l1;
toptube(jj+1, 1) = index*ls;
toptube(jj+1, 2) = h1 + 2*l2 + nl*2*l1 + h2 + l2;
% Log data to structure and add to plot. Plotting is sequential
dataFoldE(count).x = toptube(jj:jj+1, 1);
dataFoldE(count).y = toptube(jj:jj+1, 2);
dataFoldE(count).color = blue;
plot(dataFoldE(count).x, dataFoldE(count).y, 'color', ...
dataFoldE(count).color)
end
% Specify vertical line pattern (orange)
% ------------------------------------------------------------------
% Bottom tube folds and graphing
midvert = zeros(2*(n), 2);
% Ignore side folds as these are graphed by the boundary section
for kk = 2:2:2*(n)
% Increase count initially
count = count + 1;
% Indexing
index = ((kk-2)/2) + 1;
% Populate array
midvert(kk-1, 1) = index*ls;
midvert(kk-1, 2) = h1 + 2*l2;
midvert(kk, 1) = index*ls;
midvert(kk, 2) = h1 + 2*l2 + nl*2*l1;
% Log data to structure and add to plot. Plotting is sequential
dataFoldE(count).x = midvert(kk-1:kk, 1);
dataFoldE(count).y = midvert(kk-1:kk, 2);
dataFoldE(count).color = orange;
plot(dataFoldE(count).x, dataFoldE(count).y, 'color', ...
dataFoldE(count).color)
end
% Create triangular (blue)
% ------------------------------------------------------------------
% Initialize array for triangular folds
ridge = (1 + 2*nl)*(n);
trianglefolds = zeros(ridge, 2);
% Specify x and y coordinates for each column of triangles
for aa = 0:(1 + 2*nl):ridge - (1 + 2*nl)
% Increase count initially
count = count + 1;
% Indexing
index = 1 + (aa/(1 + 2*nl));
% Create a variable that will reset each loop. These will be used to
% determine where in the column each "even" or "odd" point resides.
% tower_even = 0;
% tower_odd = 0;
% Add x and y coordinates for column of triangles
for i = 1:(1 + 2*nl)
% Coordinates will differ for "even" or "odd" points
if rem(i, 2) == 0 % Even
% Determine x and y coordinates for point
trianglefolds(aa+i, 1) = (index*ls) - (l1 / tan(alpha));
trianglefolds(aa+i, 2) = h1 + 2*l2 + (i-1)*l1;
else % Odd
% Determine x and y coordinates for point
trianglefolds(aa+i, 1) = (index*ls);
trianglefolds(aa+i, 2) = h1 + 2*l2 + (i-1)*l1;
end
end
% Store to array
dataFoldE(count).x = trianglefolds(aa+1:aa+(1 + 2*nl), 1);
dataFoldE(count).y = trianglefolds(aa+1:aa+(1 + 2*nl), 2);
dataFoldE(count).color = blue;
% Plotting
plot(dataFoldE(count).x, dataFoldE(count).y, 'color', ...
dataFoldE(count).color);
end
% Create horizontal segments (blue)
% ------------------------------------------------------------------
% Initialize no fold array
h_blue = zeros(2*(n)*nl, 2);
% Loop through to store [x,y] pairs for each line segment
for bb = 0:2*nl:2*nl*(n-1)
% Indexing
index = (bb/(2*nl)) + 1;
% Add x and y coordinates for each segment
for i = 1:2*nl
% Coordinates will differ for "even" or "odd" points
if rem(i, 2) == 0 % Even
% Determine x and y coordinates for point
h_blue(bb+i, 1) = (index*ls) - (l1 / tan(alpha));
h_blue(bb+i, 2) = h1 + 2*l2 + (i-1)*l1;
else % Odd
% Determine x and y coordinates for point
h_blue(bb+i, 1) = (index-1)*ls;
h_blue(bb+i, 2) = h1 + 2*l2 + i*l1;
end
end
% Storing to data array and plotting must take place in segments of two
% points.
for j = 0:2:(2*nl)-2
% Increase count initially
count = count + 1;
dataFoldE(count).x = h_blue(bb+j+1:bb+j+2, 1);
dataFoldE(count).y = h_blue(bb+j+1:bb+j+2, 2);
dataFoldE(count).color = blue;
plot(dataFoldE(count).x, dataFoldE(count).y, 'color', ...
dataFoldE(count).color)
end
end
% Create horizontal segments (orange)
% ------------------------------------------------------------------
% Initialize orange horizontal array
h_orange = zeros(2*(n)*nl, 2);
% Loop through to store [x,y] pairs for each line segment
for cc = 0:2*nl:2*nl*(n-1)
% Indexing
index = (cc/(2*nl)) + 1;
% Add x and y coordinates for each segment
for i = 1:2*nl
% Coordinates will differ for "even" or "odd" points
if rem(i, 2) == 0 % Even
% Determine x and y coordinates for point
h_orange(cc+i, 1) = index*ls;
h_orange(cc+i, 2) = h1 + 2*l2 + (i-1)*l1;
else % Odd
% Determine x and y coordinates for point
h_orange(cc+i, 1) = (index*ls) - (l1 / tan(alpha));
h_orange(cc+i, 2) = h1 + 2*l2 + i*l1;
end
end
% Storing to data array and plotting must take place in segments of two
% points.
for j = 0:2:(2*nl)-2
% Increase count initially
count = count + 1;
dataFoldE(count).x = h_orange(cc+j+1:cc+j+2, 1);
dataFoldE(count).y = h_orange(cc+j+1:cc+j+2, 2);
dataFoldE(count).color = orange;
plot(dataFoldE(count).x, dataFoldE(count).y, 'color', ...
dataFoldE(count).color)
end
end
% Label the plot for clarity
title({
('Origami Schematic C for Provided Parameters:')
['[r = ' num2str(r) ', n = ' num2str(n) ', beta = ' num2str(beta) ...
', h0 = ' num2str(h0) ', nl = ' num2str(nl) ', dm = ' num2str(l2) ']']
})
daspect([1 1 1])
m = 0;
lmax = h1 + 2*l2 + nl*2*l1 + h2 + l2;
% close
end