%!
%% By Don Blaheta
%% 6 June 2006
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% SEE BOTTOM OF FILE FOR PARAMETERS YOU CAN MODIFY %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ar rr rt [1mconesize[0m hc ac Calculates dimensions of cone
% that constructs geodesic. ar is the
% "ring angle", the angle between the
% side of the cone and the central
% torus plane; rr is outer radius of
% the ring; rt is radius of circle
% running through centre of rings.
% Return stack: are respectively the
% hypotenuse and angle of the cone
% (angle being the sector angle of
% unwrapped cone)
/conesize {
/rt exch def
/rr exch def
/ar exch def
/rc ar cos rr mul rt add def
/hc 1 ar cos div rt mul rr add def
/ac rc hc div 360 mul def
hc ac
} def
% - [1mdrawtab[0m - Draws tab, assumes start at 0 0
/drawtab {
newpath
0 0 moveto
0.2 -0.3 lineto
wid 0.2 sub -0.3 lineto
wid 0 lineto
0 0 lineto
stroke
} def
% x y [1mdup2[0m x y x y Duplicates the top two stack elements
/dup2 {
1 index 1 index
} def
% x y r a1 a2 [1mdrawarc[0m - Either arc or arcn as appropriate
/drawarc {
dup2
gt { arcn } { arc } ifelse
} def
% off a [1moffsetrotate[0m - Rotates space at given offset
/offsetrotate {
/a exch def
/tmpoff exch def
/off tmpoff wid sub def
0 off sub 0 translate
a rotate
off 0 translate
} def
% - [1mdot[0m - Draws a dot.
/dot {
newpath
0 0 .05 0 360 arc
fill
} def
% rad a [1marcseg[0m - Draws one arc of a piece. rad is
% outer radius, a is subtended angle
/arcseg {
/a exch def
/rad exch def
newpath
0 0 moveto
wid rad sub 0 rad 0 a drawarc
wid rad sub 0 rad wid sub a 0 drawarc
0 0 lineto
stroke
} def
% ra1 ra2 tr ts [1mtoruspc[0m - Creates a single four-piece net for
% one section of a geodesic torus.
% ror is section's radius, ra are the
% absolute angles of the arc subtended
% on this cross-section. tr is the
% torus radius, ts the number of torus
% sections.
/toruspc {
/ts exch def
/tr exch def
/ra2 exch def
/ra1 exch def
gsave
drawtab
% Make toroidal section corresponding to ra1
ra1 ror tr conesize
/ac1 exch def
/hc1 exch def
/as1 ac1 ts div def
hc1 as1 arcseg
hc1 as1 offsetrotate
% Make arc of ring
ror ra2 ra1 sub arcseg
ror ra2 ra1 sub offsetrotate
% Make toroidal section corresponding to ra2
ra2 ror tr conesize
/ac2 exch def
/hc2 exch def
/as2 ac2 ts div def
hc2 as2 arcseg
hc2 as2 offsetrotate
% Make arc of ring
ror ra2 ra1 sub arcseg
grestore
} def
% tr ror wid ts rs move [1mtorus[0m - Creates all nets required for a torus
% of radius tr; with each cross-section
% ring having radius ror and the strip's
% width being wid. The torus will be
% subdivided into ts sections, and the
% ring rs sections. After each piece is
% printed, the move routine will be
% called.
/torus {
/torusmove exch def
/rs exch def
/ts exch def
/wid exch def
/ror exch def
/tor exch def
/tr tor ror 2 div sub def
/ra2 0 def
1 1 rs {/ra1 ra2 def
/ra2 ra2 360 rs div add def
1 1 1 {ra1 ra2 tr ts toruspc} for
torusmove } for
} def
% - [1mpagesetup[0m - Sets up page for layout
/pagesetup {
42 dup scale
6 2 translate
0 0 moveto
0 setlinewidth
/Times-Bold findfont
14 scalefont
setfont
} def
pagesetup
/pcno 0 def
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% YOU CAN CHANGE THESE PARAMETERS %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 % radius of torus
2 % radius of cross-section (should be less than half torus radius)
1 % width of strips (should be less than or equal to cross-sec radius)
12 % number of torus slices
6 % divisions of each slice (should not be multiple of 4)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% YOU CAN CHANGE THIS IF YOU KNOW WHAT YOU'RE DOING %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{/pcno pcno 1 add def
pcno 3 mod 0 eq
{6.5 -10 translate 0 0 moveto}
{0 5 translate 0 0 moveto}
ifelse
pcno 6 mod 0 eq
{ showpage pagesetup }
{ }
ifelse } % action after printing ea. piece
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% DON'T CHANGE THIS %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
torus
showpage