How to make pictures using postscript programs (part 11) ----------------------------------------------------------------------------- Many further interesting curves exist. The cycloids are the curves of a cycle rolling on a line, so their parameters are of the form x(t) = A*t + B*cos(t), y(t) = B*sin(t). If you attach a tracer to the wheel of your bicycle, you get this curve. --------------------------Example24------------------------------------------ %!PS-Adobe-2.0 EPSF %%Title: Cycloid %%BoundingBox: 0.0 100.0 520 320 10 210 translate newpath 0 30 moveto 0 3 1030 {/t exch def t sin 30 mul t 0.51 mul add t cos 30 mul lineto } for stroke showpage ----------------------------------------------------------------------------- If you have a cycle moving around a center which itself is moving on a cycle, you get a family of curves called epicycloids; they are the overlay of two circular movements. Before the copernican revolution, placing the sun in the center, the planetary motions were described by these curves. A parametrization looks like x(t) = A*cos(t) + B*cos(C*t), y(t) = A*sin(t) + B*sin(C*t) --------------------------Example25------------------------------------------- %!PS-Adobe-2.0 EPSF %%Title: Epicykloid %%BoundingBox: 0.0 0.0 420 420 210 210 translate newpath 0 60 moveto 0 3 360 {/t exch def t sin 30 mul t 3 mul sin 30 mul add t cos 30 mul t 3 mul cos 30 mul add lineto } for stroke showpage ------------------------------------------------------------------------------ If we do not want to compute the first point, which we need, because it is moveto instead of lineto, we just set a variable to keep track whether this is the first point, and then have an if statement to select `moveto' or `lineto'. ---------------------------Example26------------------------------------------ %!PS-Adobe-2.0 EPSF %%Title: Epicykloid, code adjusted to make first point moveto, then lineto %%BoundingBox: 0.0 0.0 420 420 210 210 translate /first 0 def newpath 0 1 360 {/t exch def t sin 50 mul t 6 mul cos 30 mul add %x coordinate t cos 50 mul t 6 mul sin 30 mul add %y coordinate first 0 eq {moveto /first 1 def} % if first, thhen moveto {lineto} ifelse % else lineto } for stroke showpage