aboutsummaryrefslogtreecommitdiff
path: root/src/input/tknot.input.pamphlet
blob: 707a42654b2355e3937b6fcccd9ea6791ada6c44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
\documentclass{article}
\usepackage{axiom}
\begin{document}
\title{\$SPAD/src/input tknot.input}
\author{The Axiom Team}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\eject
\section{License}
<<license>>=
--Copyright The Numerical Algorithms Group Limited 1994.
@
<<*>>=
<<license>>
-- Create a (p,q) torus-knot with radius r around the curve.
-- The formula was derived by Larry Lambe.

-- To produce a trefoil knot:
--   torusKnot(2, 3, 0.5, 10, 200)

-- compile, don't interpret functions
)set function  compile on

-- read in the numeric generalized tube program
)read ntube

-- Create a (p,q) torus-knot with radius r around the curve.
-- The formula was derived by Larry Lambe.
-- To produce a trefoil knot:
--   torusKnot(2, 3, 0.5)
torusKnot(p:DFLOAT, q:DFLOAT, r:DFLOAT, uSteps:PI, tSteps:PI):VIEW3D ==
  -- equation for the torus knot
  knot := (t:DFLOAT):Point DFLOAT +-> 
    fac := 4/(2.2@DFLOAT-sin(q*t))
    fac * point [cos(p*t), sin(p*t), cos(q*t)]
  -- equation for the cross section of the tube
  circle := (u:DFLOAT, t:DFLOAT):Point DFLOAT +->
    r * point [cos u, sin u]
  -- draw the tube around the knot
  ntubeDrawOpt(knot, circle, 0..2*%pi, 0..2*%pi, var1Steps == uSteps, 
               var2Steps == tSteps)


@
\eject
\begin{thebibliography}{99}
\bibitem{1} nothing
\end{thebibliography}
\end{document}