% Antoine's Necklace 
% Rob Scharein - April 20, 1996

% For a discussion of the fundamental group of the complement
% of Antoine's Necklace, see `Knots and Links'. 

% Function key F1 can be used to read in this file again.
% F2 will resize the view window. 

% To use this script, enter the KnotPlot command:
% 
%     KnotPlot> <make-antoines-necklace
%
% or
%
%     KnotPlot> read make-antoines-necklace
%
% After it's been loaded once you can reload it by pressing the F1 key.
% 

func 1 <make-antoines-necklace
func 2 <resize-window

% Comment out the following line if you want to see the construction.

Draw=f

% Set up the viewing coordinate system, these numbers may be
% changed for different effects.

untran
rot x -55
scale = .495
try = 1.667

cyl = .07             % radius of smooth tubes.

lxnseg = 20           % quality factors
lxncur = 6            % for `luxo' mode.

chnseg = 8            % quality factors
chncur = 2            % for `cheapo' mode.

pop                   % pop the view window forward.

clrf zf               % these are the default clear functions, here
                      % in case they need to be reset.


% Perhaps the following number should be 40 instead of 20, since each
% stage of the construction should replace every component ring by the
% same number of sub-rings.  But actually it doesn't really matter much
% as the final object will still be a Cantor set.  The exact value of 
% the fractal dimension will depend on details such as these, however.
% The main reason for 20 instead of 40 is that it produces a better picture
% than either 20 at every stage or 40 at every stage.

chain 20 7            % create a chain with 20 rings of 7 beads each.

fitto 1.5             % fit it to size of 1.5

save /tmp/KP-antoines-necklace.dum    % save it as a temporary file.

trans 10                              % translate it 10 units in x direction.
save /tmp/KP-antoines-necklace.dumm   % save the translated version.
load /tmp/KP-antoines-necklace.dum    % load the untranslated version.
about y 90                            % rotate it about the y-axis        
trans 10                              % and translate it by 10.
about z 9                             % rotate it so it'll link with dumm.

load comb /tmp/KP-antoines-necklace.dumm  % combine with dumm, now we have
                                          % one pair of linked rings.
% remove all the dummy files.

!/bin/rm /tmp/KP-antoine*

sbuff                                     % switch to single buffer mode
                                          % so that we can draw in an 
                                          % accumulating mode.

% Modify the file randomize-colours to get different effects.

sat=1
value=1
cmode 0               % This undoes any other cmode commands.
<randomize-colours

disp t          % clear the frame buffer
disp t          % (twice), maybe not really needed.
clrf n          % turn off clearing of frame buffers.

Draw=f    % This line should not be commented out.  Want to explicitly issue
          % drawing commands.

silent = t

% Draw the first big ring by duplicating it 19 more times.

#19 about z 18;disp t;<randomize-colours

% set up the coord system to draw right hand big ring.

rot x 90
trx = 7

#20 about z 18; disp t;<randomize-colours


% set up the coord system to draw left hand big ring.

trx = -7

#20 about z 18; disp t;<randomize-colours

delete all
Draw=t

silent = f


