Pro Python remarks to math ed folks (pointers)

Kirby Urner urner at alumni.princeton.edu
Tue Aug 24 15:45:06 EDT 1999


Skip Montanaro <skip at mojam.com> wrote:

>Are quadrays similar/identical to quadrics?  If so, why the change in
>nomenclature?
>

No, quadrays and quadrics aren't closely related.  

Quadrays are like the XYZ coordinate system.  XYZ is shaped like 
a "jack" with six spokes to the vertices of a regular octahedron.  

The quadray apparatus, in contrast, consists of four spokes to 
the corners of a regular tetrahedron, labeled (1,0,0,0)(0,1,0,0)
(0,0,1,0) and (0,0,0,1).  The center of the tetrahedron is 
(0,0,0,0) -- this is ordinary volume, not R^4.  

Also I've made the design decision to have this "home base" tetra-
hedron come out with edges of length two (for reasons I maybe 
shouldn't go into here), so Vector(quad=(1,0,0,0)).length() is 
not 1, but root(6)/2

They come closest to being a brand of "simplicial coordinates"
(basing my remarks on a post by Dr. John Conway to geometry_
research) but I'm not sure they fit there either, as we don't
normally normalize to zero, i.e. we don't require a+b+c+d=0
when we write (a,b,c,d) -- just like we don't require this 
of (x,y,z) 3-tuples either.

Here's some dialog in the Python environment to give you 
the flavor:

>>> from vector import Vector
>>> Vector(quad=(1,0,0,0)).length()
1.22474487139
>>> Vector(xyz=(1,0,0)).length()
1.0
>>> v1 = Vector(quad=(1,0,0,0))
>>> v1.data     # default data tuple is in quadray format
(1, 0, 0, 0)
>>> v1.length()
1.22474487139
>>> v1.xyz()     # xyz and polar formats available as conversions
(0.707106781187, 0.707106781187, 0.707106781187)
>>> v1.polar()   # output is (radius,angle,angle), angles in degrees
(1.22474487, 45.0, 35.26438968)
>>> v2=v1*2      # operator overloading (scale vector by 2)
>>> v2.data
(2, 0, 0, 0)
>>> v3=v1+v2
>>> v3.data
(3, 0, 0, 0)
>>> v3.length()
3.67423461417
>>> v4=v3.rotate((0,0,0,120))
>>> v4.data
(0.0, 3.0, 0.0, 0.0)
>>> v4.xyz()
(-2.12132034356, -2.12132034356, 2.12132034356)
>>> v4.polar()
(3.67423461, 225.0, 35.26438968)
>>> v1.angle(v4) # angle between the two vectors v1 and v4
109.47122

For more on quadrays, visit my 
http://www.teleport.com/~pdx4d/quadintro.html -- written in
simple language not presuming a lot of background (target 
audience might be 8th-12th graders).

Kirby

PS:  for those following this thread to the point of trying to
run my code, I should add that I'm importing a couple methods
from NumPy package (free download from Lawrence Livermore Labs).
I know that's a pretty standard add-on, but of course it's not
part of the native Python installation.  Would be easy enough 
to rewrite the bits where I've made use of these methods, but
keeping NumPy in the picture is easier still.

Code is at http://www.inetarena.com/~pdx4d/ocn/python/

Haven't yet written the supporting documentation that would 
make this easier to use.  Mostly just wanting to share my 
enthusiasm, as a curriculum writer, for Python as a teaching
language.  But way cool if people are up for downloading and
testing as well.





More information about the Python-list mailing list