New KnotPlot Commands

This page describes some new KnotPlot commands that have not yet made it into the manual.

Creating things

Hedgehog knots

hedgehog Nbeads EdgeLength
creates a hedgehog knot with Nbeads vertices (beads) and edges of length EdgeLength. Parameters may be omitted and they will default to something reasonable.

Spooling model

spool Nbeads R r h
creates a knot using the spooling model with Nbeads vertices using the parameters R, r and h. Parameters may be omitted, for example:
spool 108


Simple looping using the frame command

frame command CommandString
sets the frame command string to CommandString. Nothing is actually executed or computed at this point. Only the value of the command string is set. Something actually happens when you do a
frame FrameNumber
command, where FrameNumber is an integer. What happens is that the integer FrameNumber gets written into the current frame command string using the same convention as the printf() function from the C programming language. Any %d field found in the frame command string gets replaced with the value of the frame number. Fields such as %03d are handled in the same way as in printf(). Also, the frame command string may have more than one such field.
As an example, suppose we've set the frame command string to be
frame command "knot number %d"
and then we do a
frame 108
This would be the same as entering the command knot number 108 into KnotPlot (which will load the knot 1023).
It is possible to loop thru a sequence of frames. For example,
frame 6 to 8
is the same as entering in sequence the commands frame 6, frame 7 and frame 8.
The step size need not be equal to one,
frame 10 to 40 step 10
is the same as entering in sequence the commands frame 10, frame 20, frame 30 and frame 40.
You can also specify a starting frame and the total number of frames to do,
frame 4 number 10
is the same as entering in sequence the commands frame 4, frame 5, frame 6, ... frame 13.

Creating command aliases

alias AliasName CommandString
creates the alias with the name AliasName and sets its value to be CommandString, which is any KnotPlot command or sequence of commands. For example, suppose we define the alias det using the command
alias det "alex -1"
and then we enter
The result will be the same as entering alex -1
A sequence of commands may be specified by separating the commands with a semi-collons:
alias ~loadnreflect "load 3.1;reflect z;energy"

Also, the aliases can take parameters. The parameters are numbered starting at 0, and are denoted with a dollar sign, i.e., $0, $1, $2, … So, for example if we define
alias ~loadnsquish "knot number $0;scale 1 1 .3"
then entering ~loadnsquish 3 would be equivalent to the commands
knot number 3
scale 1 1 .3

entered in sequence.
If we define alias ~gumby "torus $0 $1;scale $3 1 $2"
and then enter ~gumby 4 7 .23 1.08 it would be the same result as entering
torus 4 7
scale 1.08 1 .23

(note that the parameter fields in the alias command string needn't follow numerical order).

Saving data to a file

data open FileName
opens the plain-text file FileName to receive data. This could be a CSV (comma separated value) file for import into a spreadsheet, or just a regular text file. If the former, it makes sense to give the file a .csv extension, otherwise the file name is arbitrary.

data format DataFormat
sets the data format to DataFormat, which should be a string inside of double quotes. The data format tells KnotPlot what quantities to write to the data file. For example,
data format "/g"
says to write only the radius of gyration.
If your data file is a CSV file, just put commas in the format field. For example,
data format "/N, /D"
says to save the number of beads and the Alexander polynomial evaluated (see below), separated by a comma and space.

data header DataHeader
writes out the text DataHeader verbatim to the data file. DataHeader can optionally contain one or more codes to write the hostname of the computer KnotPlot is running on, the user name and also the date and time of the run. For example, the line
data header "run on /* at /@ by /?"
might write something like
run on Volta at Thu Sep 23 09:28:13 2010 by rob
data header
without arguments writes a line to the data file, based on the current DataFormat. Instead of values, the names of the fields are written. For example, if the current DataFormat is "/N, /W, /g" then data header will write the line
Nbeads, Space Writhe, RoG
If you don't like the names KnotPlot choses for the fields, then specify the names explicitly using a suitable DataHeader.

The command
(without parameters) writes one line of data into the opened data file. What gets written depends on the current data format that is set. Note that data doesn't do any calculations itself, it simply writes the values of any previously computed quanties out to the data file. If you want to record radius of gyration, for example, you need to issue a rog command before the data command.

The final command option is
data close
which closes the data file (if opened).

Many KnotPlot quantities can be saved using the data command. Here is a list of the format fields and what they correspond to:
/h homfly polynomial
/i ID (data record number)
/w writhe
/W space writhe
/f last file loaded
/d Dowker code
/e energy (current energy model)
/a ACN (exact)
/B bridge number
/b ABN
/I iteration
/L linking number
/U unsigned linking number
/F full linking number information (upper triangular
   part of linking matrix, including the diagonal)
/l length
/A angle
/N nbeads
/t thickness
/q eqmeasure (Rawdon-Millett measure)
/s safeness
/H hausdorff distance
/g radius of gyration
/D Alexander polynomial evaluated

An example KnotPlot script file using the data command, example.txt, and the CSS file, test1.csv resulting from running this script are available.


Knot length

This command is actually an old one, but for reasons unknown (but time will tell), it's not in the manual:
calculates information about the knot length, printing something of the form:
Length in short direction = 5.654867
#0: Nb 135  tot 165.567166 aspect 29.28      min 1.167330 (80) max 1.365923 (96) max/min = 1.170125 aver 1.226423
This says that for component number 0, there are 135 beads. Total length is 165.567166. Edge 80 has the shortest length with a length of 1.167330 and edge 96 with a length of 1.365923. The ratio of the maximum to minimum edge lengths is 1.170125 and the average length of the edges is 1.226423. If you have a multi-component knot (a link), you will get one line of information per component.

Radius of gyration

The new command
calculates the radius of gyration of the knot. It has no options or parameters.

Alexander polynomial evaluated

The alex command has been around for years, but it now can take a numerical argument. The most common usage of the new command would be
alex -1
which calculates the absolute value of the Alexander polynomial evaluated at -1. This is also known as the knot determinant and is a simple (but not perfect) measure of knottedness. If you frequently need to enter the above command, it might make sense to make an alias:
alias det "alex -1"
and then you can simply enter det to compute the determinant.
Rob Scharein (
Hypnagogic Software
17 November 2017

Valid XHTML 1.0 Strict