File: cycld_1.ldf

package info (click to toggle)
3dldf 2.0.3%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 12,508 kB
  • ctags: 7
  • sloc: makefile: 892; sh: 117; cpp: 5
file content (364 lines) | stat: -rw-r--r-- 7,623 bytes parent folder | download | duplicates (2)
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
%%%% cycld_1.ldf
%%%% Created by Laurence D. Finston (LDF) Mon Aug 18 17:31:48 CEST 2008

%% * (1) Copyright and License.

%%%% This file is part of GNU 3DLDF, a package for three-dimensional drawing.  
%%%% Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 The Free Software Foundation  

%%%% GNU 3DLDF is free software; you can redistribute it and/or modify 
%%%% it under the terms of the GNU General Public License as published by 
%%%% the Free Software Foundation; either version 3 of the License, or 
%%%% (at your option) any later version.  

%%%% GNU 3DLDF is distributed in the hope that it will be useful, 
%%%% but WITHOUT ANY WARRANTY; without even the implied warranty of 
%%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
%%%% GNU General Public License for more details.  

%%%% You should have received a copy of the GNU General Public License 
%%%% along with GNU 3DLDF; if not, write to the Free Software 
%%%% Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 

%%%% GNU 3DLDF is a GNU package.  
%%%% It is part of the GNU Project of the  
%%%% Free Software Foundation 
%%%% and is published under the GNU General Public License. 
%%%% See the website http://www.gnu.org 
%%%% for more information.   
%%%% GNU 3DLDF is available for downloading from 
%%%% http://www.gnu.org/software/3dldf/LDF.html.

%%%% Please send bug reports to Laurence.Finston@gmx.de
%%%% The mailing list help-3dldf@gnu.org is available for people to 
%%%% ask other users for help.  
%%%% The mailing list info-3dldf@gnu.org is for sending 
%%%% announcements to users. To subscribe to these mailing lists, send an 
%%%% email with ``subscribe <email-address>'' as the subject.  

%%%% The author can be contacted at: 

%%%% Laurence D. Finston 
%%%% c/o Free Software Foundation, Inc. 
%%%% 51 Franklin St, Fifth Floor 
%%%% Boston, MA  02110-1301  
%%%% USA

%%%% Laurence.Finston@gmx.de
 


%% Last updated:  August 14, 2008

%% Run like this:

%% 3dldf cycld_1.ldf 
%% mpost cycld_1.mp 
%% tex cycld_1.txt 
%% dvips -o cycld_1.ps cycld_1.dvi

%% All on one line:
if false:
3dldf cycld_1.ldf; mpost cycld_1.mp; tex cycld_1.txt; \
dvips -o cycld_1.ps cycld_1.dvi
fi;

%% View using Ghostview like this:
%% gv cycld_1.ps &

%% Generate animated GIF like this:
%% conveps --start=0 --end=121 --output-format=jpeg --border=0 cycld_1
%% convert -delay 15 cycld_1_*.jpg cycld_1.gif
%%
%% Other formats can be used;  it doesn't have to be JPEG.

%% The animated GIF can be viewed using the `animate' program from ImageMagick:
%% animate cycld_1.gif 

%% * (1) Beginning of 3DLDF code.

%% ** (2) Cycloid Pattern 1

pickup pencircle scaled (.675mm, .675mm, .675mm);

circle c[];
point p[];
path q[];
transform t[];

m := 7;
n := 7;

q2 := (-m, 0, -n) -- (m, 0, -n) -- (m, 0, n) -- (-m, 0, n) -- cycle;

numeric d[];
d0 := 5;
d1 := d0 / 5;

numeric r[];

r0 := .5d0;
r1 := .5d1;

set c0 with_diameter d0 with_point_count 32;
set c1 with_diameter d1;

pi := 3.141592653589793;

alpha := 3 * 2pi / 360;

dist := r0 * alpha;

if false: 
   message "2pi:"; 
   show 2pi;
   message "dist:"; 
   show dist;
fi; 

beta := dist / r1;  %% angle of rotation of c1 about its center.

if false: 
   message "beta in radians:"; 
   show beta;

   message "alpha in radians:"; 
   show alpha;
fi;

alpha *= 180;
alpha /= pi;

beta *= 180;
beta /= pi;

if false: 
   message "alpha in deg:"; 
   show alpha;

   message "beta in deg.:"; 
   show beta;
fi; 

p0 := get_point 8 c0;


shift c1 by p0;
shift c1 by (0, 0, .5d1);

p1 := get_center c1;
p2 := p1 shifted (0, 1);


q0 := origin -- p1;

q1 += p0;

beginfig(1);
draw p0 -- p1;
draw q2;
draw c0;
draw c1;
draw q0;

if false: 
   dotlabel.bot("o", origin);
   dotlabel.lrt("$p_0$", p0);
   dotlabel.rt("$p_1$", p1);
fi; 

endfig with_projection parallel_x_z no_sort;  

t0 := identity rotated (0, alpha);

for i = 2 upto 121:
   beginfig(i);
      draw q2;
      p0 *= p1 *= p2 *= c1 *= q0 *= t0;
      t1 := identity rotated_around (p1, p2) beta;

      p0 *= c1 *= t1;

      q1 += ..;
      q1 += p0;

      draw p0 -- p1;
      draw c0;
      draw c1;
      draw q0;

      draw q1 with_color blue;


      if false: 
         dotlabel.bot("o", origin);
         dotlabel.lrt("$p_0$", p0);
         dotlabel.rt("$p_1$", p1);
      fi; 

   endfig with_projection parallel_x_z no_sort;  
endfor;

shift p0 (0, 0, -.5);
q1 += cycle;  %% Correction.  LDF 2009.01.09.

for i = 122 upto 240:
   beginfig(i);
      draw q2;
      draw q1 with_color blue;
      p0 *= p1 *= p2 *= c1 *= q0 *= t0;
      t1 := identity rotated_around (p1, p2) 15;

      p0 *= c1 *= t1;

      q3 += ..;
      q3 += p0;

      draw p0 -- p1;
      draw c0;
      draw c1;
      draw q0;
      draw q3 with_color red;

      if false: 
         dotlabel.bot("o", origin);
         dotlabel.lrt("$p_0$", p0);
         dotlabel.rt("$p_1$", p1);
      fi; 

   endfig with_projection parallel_x_z no_sort;  
endfor;

shift p0 (0, 0, 1.5);
q3 += cycle;

for i = 241 upto 361:
   beginfig(i);
      draw q2;
      draw q1 with_color blue;
      draw q3 with_color red;
      p0 *= p1 *= p2 *= c1 *= q0 *= t0;
      t1 := identity rotated_around (p1, p2) 15;

      p0 *= c1 *= t1;

      q4 += ..;
      q4 += p0;

      if i == 361:
         q4 += cycle;
      fi;

      draw p0 -- p1;
      draw c0;
      draw c1;
      draw q0;
      draw q4 with_color green;

      if false: 
         dotlabel.bot("o", origin);
         dotlabel.lrt("$p_0$", p0);
         dotlabel.rt("$p_1$", p1);
      fi; 

   endfig with_projection parallel_x_z no_sort;  
endfor;

shift p0 (0, 0, -2.0);
q4 += cycle;

for i = 362 upto 482:
   beginfig(i);
      draw q2;
      draw q1 with_color blue;
      draw q3 with_color red;
      draw q4 with_color green;
      p0 *= p1 *= p2 *= c1 *= q0 *= t0;
      t1 := identity rotated_around (p1, p2) 15;

      p0 *= c1 *= t1;

      q5 += ..;
      q5 += p0;

      if i == 361:
         q5 += cycle;
      fi;

      draw p0 -- p1;
      draw c0;
      draw c1;
      draw q0;
      draw q5 with_color orange;

      if false: 
         dotlabel.bot("o", origin);
         dotlabel.lrt("$p_0$", p0);
         dotlabel.rt("$p_1$", p1);
      fi; 

   endfig with_projection parallel_x_z no_sort;  
endfor;


p0 := get_point 7 c0;

p1 := unit_vector p0;
p1 *= r1;
p1 += p0;
p2 := p1 shifted (0, 1);

set c1 with_diameter d1;

shift c1 by p1;

q0 := origin -- p1;

beginfig(483);
draw q2;
draw q1 with_color blue;
draw q3 with_color red;
draw q4 with_color green;
draw q5 with_color orange;

draw p0 -- p1;
draw q2;
draw c0;
draw c1;
draw q0;

if false: 
   dotlabel.bot("o", origin);
   dotlabel.lrt("$p_0$", p0);
   dotlabel.rt("$p_1$", p1);
fi; 

endfig with_projection parallel_x_z no_sort;  

%% *** (3) End of 3DLDF code

verbatim_metapost "end;";

end;

%% ** (2) 

%% * (1) Emacs-Lisp code for use in indirect buffers when using the          
%%   	 GNU Emacs editor.  The local variable list is not evaluated when an 
%%   	 indirect buffer is visited, so it's necessary to evaluate the       
%%   	 following s-expression in order to use the facilities normally      
%%   	 accessed via the local variables list.                              
%%   	 \initials{LDF 2004.02.12}.                                          

%% (progn (metafont-mode) (outline-minor-mode t) (setq fill-column 80) (ignore '(  
%% )) (setq outline-regexp "%% [*\f]+"))

%% * (1) Local variables for Emacs.

%% Local Variables:
%% mode:Metafont
%% eval:(outline-minor-mode t)
%% eval:(read-abbrev-file abbrev-file-name)
%% outline-regexp:"%% [*\f]+"
%% End: