Add: spirograph.ps
This commit is contained in:
54
spirograph.ps
Normal file
54
spirograph.ps
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
%!PS
|
||||||
|
/R {144} def
|
||||||
|
/r {89} def
|
||||||
|
/h {55} def
|
||||||
|
|
||||||
|
% options
|
||||||
|
0.1 setlinewidth
|
||||||
|
2 setlinecap
|
||||||
|
2 setlinejoin
|
||||||
|
|
||||||
|
% set origin on center of page
|
||||||
|
/in {72 mul} def
|
||||||
|
8.5 in 2 div
|
||||||
|
11 in 2 div
|
||||||
|
translate
|
||||||
|
|
||||||
|
% Position x(t), y(t)
|
||||||
|
/x {
|
||||||
|
/t exch def
|
||||||
|
R r sub t cos mul
|
||||||
|
t 1 R r div sub mul cos h mul
|
||||||
|
add
|
||||||
|
% Normalize
|
||||||
|
144 mul R r sub h add div
|
||||||
|
} def
|
||||||
|
|
||||||
|
/y {
|
||||||
|
/t exch def
|
||||||
|
R r sub t sin mul
|
||||||
|
t 1 R r div sub mul sin h mul
|
||||||
|
add
|
||||||
|
% Normalize
|
||||||
|
144 mul R r sub h add div
|
||||||
|
} def
|
||||||
|
|
||||||
|
% a=mcd{r,R}
|
||||||
|
/a {r} def
|
||||||
|
/b {R} def
|
||||||
|
{
|
||||||
|
b 0 ne exit if
|
||||||
|
/x {a b mod} def
|
||||||
|
/a {b} def
|
||||||
|
/b {x} def
|
||||||
|
} loop
|
||||||
|
|
||||||
|
% Draw
|
||||||
|
0 x 0 y moveto
|
||||||
|
0 1 360 r r mul mul a div
|
||||||
|
{
|
||||||
|
dup x exch y lineto
|
||||||
|
} for
|
||||||
|
|
||||||
|
stroke
|
||||||
|
showpage
|
||||||
Reference in New Issue
Block a user