aboutsummaryrefslogtreecommitdiff
path: root/src/input/images1a.input.pamphlet
blob: 4164de0b4421ece2105d610e1942d3f7eb012aa2 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
\documentclass{article}
\usepackage{axiom}
\begin{document}
\title{\$SPAD/src/input images1a.input}
\author{The Axiom Team}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\eject
\section{License}
<<license>>=
--Copyright The Numerical Algorithms Group Limited 1994-1996.
@
<<*>>=
<<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

-- Generalized tubes.
-- These functions draw a 2-d curve in the normal
-- planes around a 3-d curve.  The computations are all done
-- numerically in machine-precision floating point for efficiency.

R3 := Point DoubleFloat                  -- Points in 3-Space
R2 := Point DoubleFloat                  -- Points in 2-Space
S := Segment Float              -- Draw ranges
ThreeCurve := DoubleFloat -> R3          -- type of a space curve function
TwoCurve := (DoubleFloat, DoubleFloat) -> R2      -- type of a plane curve function
Surface := (DoubleFloat, DoubleFloat) -> R3   -- type of a parameterized surface function

-- Frenet frames define a coordinate system around a point on a space curve
FrenetFrame := Record(value: R3, tagent: R3, normal: R3, binormal: R3)

-- Holds current Frenet frame for a point on a curve
frame: FrenetFrame

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

-- Draw a generalized tube.
-- ntubeDraw(spaceCurve, planeCurve, u0..u1, t0..t1)
-- draws planeCurve int the normal planes of spaceCurve.  u0..u1 specifies
-- the paramter range of the planeCurve and t0..t1 specifies the parameter
-- range of the spaceCurve.  Additionally the plane curve function takes
-- as a second parameter the current parameter of the spaceCurve.  This
-- allows the plane curve to evolve as it goes around the space curve.
-- see "page5.input" for an example of this.
ntubeDraw: (ThreeCurve, TwoCurve, S, S) -> VIEW3D
ntubeDraw(spaceCurve, planeCurve, uRange, tRange) ==
  ntubeDrawOpt(spaceCurve, planeCurve, uRange, tRange, []$List DROPT)

-- ntuberDrawOpt is the same as ntuberDraw, but takes optional
-- parameters which it passes to the draw command.
ntubeDrawOpt: (ThreeCurve, TwoCurve, S, S, List DROPT) -> VIEW3D
ntubeDrawOpt(spaceCurve, planeCurve, uRange,  tRange, l) ==
  delT:DoubleFloat := (hi(tRange) - lo(tRange))/10000
  oldT:DoubleFloat := lo(tRange) - 1
  fun := ngeneralTube(spaceCurve, planeCurve, delT, oldT)
  draw(fun, uRange, tRange, l)

-- nfrenetFrame(c, t, delT) numerically computes the Frenet Frame
-- about the curve c at t.  delT is a small number used to
-- compute derivatives.
nfrenetFrame(c, t, delT) ==
  f0 := c(t)
  f1 := c(t+delT)
  t0 := f1 - f0                -- the tangent
  n0 := f1 + f0
  b := cross(t0, n0)           -- the binormal
  n := cross(b,t0)             -- the normal
  ln := length n
  lb := length b
  ln = 0 or lb = 0 => error "Frenet Frame not well defined"
  n := (1/ln)*n                -- make into unit length vectors
  b := (1/lb)*b
  [f0, t0, n, b]$FrenetFrame

-- nGeneralTube(spaceCurve, planeCurve, delT, oltT)
-- creates a function which can be passed to the system draw command.
-- The function is a parameterized surface for the general tube
-- around the spaceCurve.  delT is a small number used to compute
-- derivatives, and oldT is used to hold the current value of the
-- t parameter for the spaceCurve.  This is an efficiency measure
-- to ensure that frames are only computed once for every value of t.
ngeneralTube: (ThreeCurve, TwoCurve, DoubleFloat, DoubleFloat) -> Surface
ngeneralTube(spaceCurve, planeCurve, delT, oldT) ==
  free frame
  (v:DoubleFloat, t: DoubleFloat): R3 +->
    if (t ~= oldT) then
      frame := nfrenetFrame(spaceCurve, t, delT)
      oldT := t
    p := planeCurve(v, t)
    frame.value + p.1*frame.normal + p.2*frame.binormal

-- 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)


-- draw a (15,17) torus knot

torusKnot(15,17, 0.1, 6, 700)
@
\eject
\begin{thebibliography}{99}
\bibitem{1} nothing
\end{thebibliography}
\end{document}