/usr/share/axiom-20170501/src/algebra/TUBETOOL.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | )abbrev package TUBETOOL TubePlotTools
++ Author: Clifton J. Williamson
++ Date Created: Bastille Day 1989
++ Date Last Updated: 5 June 1990
++ Description:
++ Tools for constructing tubes around 3-dimensional parametric curves.
TubePlotTools() : SIG == CODE where
I ==> Integer
SF ==> DoubleFloat
L ==> List
Pt ==> Point SF
SIG ==> with
point : (SF,SF,SF,SF) -> Pt
++ point(x1,x2,x3,c) creates and returns a point from the three
++ specified coordinates \spad{x1}, \spad{x2}, \spad{x3}, and also
++ a fourth coordinate, c, which is generally used to specify the
++ color of the point.
"*" : (SF,Pt) -> Pt
++ s * p returns a point whose coordinates are the scalar multiple
++ of the point p by the scalar s, preserving the color, or fourth
++ coordinate, of p.
"+" : (Pt,Pt) -> Pt
++ p + q computes and returns a point whose coordinates are the sums
++ of the coordinates of the two points \spad{p} and \spad{q}, using
++ the color, or fourth coordinate, of the first point \spad{p}
++ as the color also of the point \spad{q}.
"-" : (Pt,Pt) -> Pt
++ p - q computes and returns a point whose coordinates are the
++ differences of the coordinates of two points \spad{p} and \spad{q},
++ using the color, or fourth coordinate, of the first point \spad{p}
++ as the color also of the point \spad{q}.
dot : (Pt,Pt) -> SF
++ dot(p,q) computes the dot product of the two points \spad{p}
++ and \spad{q} using only the first three coordinates, and returns
++ the resulting \spadtype{DoubleFloat}.
cross : (Pt,Pt) -> Pt
++ cross(p,q) computes the cross product of the two points \spad{p}
++ and \spad{q} using only the first three coordinates, and keeping
++ the color of the first point p. The result is returned as a point.
unitVector : Pt -> Pt
++ unitVector(p) creates the unit vector of the point p and returns
++ the result as a point. Note that \spad{unitVector(p) = p/|p|}.
cosSinInfo : I -> L L SF
++ cosSinInfo(n) returns the list of lists of values for n, in the form
++ \spad{[[cos(n-1) a,sin(n-1) a],...,[cos 2 a,sin 2 a],[cos a,sin a]]}
++ where \spad{a = 2 pi/n}. Note that n should be greater than 2.
loopPoints : (Pt,Pt,Pt,SF,L L SF) -> L Pt
++ loopPoints(p,n,b,r,lls) creates and returns a list of points
++ which form the loop with radius r, around the center point
++ indicated by the point p, with the principal normal vector of
++ the space curve at point p given by the point(vector) n, and the
++ binormal vector given by the point(vector) b, and a list of lists,
++ lls, which is the \spadfun{cosSinInfo} of the number of points
++ defining the loop.
CODE ==> add
import PointPackage(SF)
point(x,y,z,c) == point(l : L SF := [x,y,z,c])
getColor: Pt -> SF
getColor pt == (maxIndex pt > 3 => color pt; 0)
getColor2: (Pt,Pt) -> SF
getColor2(p0,p1) ==
maxIndex p0 > 3 => color p0
maxIndex p1 > 3 => color p1
0
a * p ==
l : L SF := [a * xCoord p,a * yCoord p,a * zCoord p,getColor p]
point l
p0 + p1 ==
l : L SF := [xCoord p0 + xCoord p1,yCoord p0 + yCoord p1,_
zCoord p0 + zCoord p1,getColor2(p0,p1)]
point l
p0 - p1 ==
l : L SF := [xCoord p0 - xCoord p1,yCoord p0 - yCoord p1,_
zCoord p0 - zCoord p1,getColor2(p0,p1)]
point l
dot(p0,p1) ==
(xCoord p0 * xCoord p1) + (yCoord p0 * yCoord p1) +_
(zCoord p0 * zCoord p1)
cross(p0,p1) ==
x0 := xCoord p0; y0 := yCoord p0; z0 := zCoord p0;
x1 := xCoord p1; y1 := yCoord p1; z1 := zCoord p1;
l : L SF := [y0 * z1 - y1 * z0,z0 * x1 - z1 * x0,_
x0 * y1 - x1 * y0,getColor2(p0,p1)]
point l
unitVector p == (inv sqrt dot(p,p)) * p
cosSinInfo n ==
ans : L L SF := nil()
theta : SF := 2 * pi()/n
for i in 1..(n-1) repeat --!! make more efficient
angle := i * theta
ans := concat([cos angle,sin angle],ans)
ans
loopPoints(ctr,pNorm,bNorm,rad,cosSin) ==
ans : L Pt := nil()
while not null cosSin repeat
cossin := first cosSin; cos := first cossin; sin := second cossin
ans := cons(ctr + rad * (cos * pNorm + sin * bNorm),ans)
cosSin := rest cosSin
pt := ctr + rad * pNorm
concat(pt,concat(ans,pt))
|