Google+ Badge

Facebook

Sunday, April 29, 2012

Geometry As An Interactive Design Space

I've been somewhat coy about the software project I'm working on; that was exacerbated by my having to take a break from working on it for some months to deal with other aspects of Real Life ; now I want to talk about it in some detail, and show you why I'm interested in it, and what I hope will come out of it. If you haven't yet read my previous post on "The Geometry of the Many-Angled Ones", please follow that link and read it; there's a very basic description of Geometric Algebra there, and that's the basis of the software I'm designing. When you come back, jump past the cut for the rest if this post.

-------------------------

I've loved the study of Geometry for a very long time, partly because its visual aspect appeals to my sense of visual aesthetics, partly because of the elegant way that modern geometry is built on top of symmetry groups, and partly because it's the basis for a lot of beautiful mathematical art. One fascinating way to study (oh, tell the truth, to play with) geometry is with a kind of software called a dynamic geometry environment. To the casual user, this looks like a drawing program with some specialized graphic objects and ways to create and measure lengths, areas, volumes, and angles.  Some are 2D, with objects like points, line segments, rays, and lines, circles, and polygons and some are 3D, adding planes, spheres, and polyhedra. The key addition is the ability to constrain objects and groups of objects in various ways.  For instance, creating a line segment whose endpoints are the centers of two circles, or a sphere whose center point always resides in a given plane.

The diagram below was created in a free dynamic geometry program called GeoGebra.  I drew 2 circles and connected the centers with a line segment.  Then I created a point where the line segment intersected each of the circles, and created a line tangent to the circle at each of the intersection points, and put an angle measurer on each of those intersections.  Each of those operations was a single pick from a menu and then selecting or creating one or more points or lines. Here's the list of created objects:

             No.
Name
  Definition
Value
             1
Point A

A = (-0.02, 2.62)
             2
Point B

B = (-1.62, 3.7)
             3
Circle c
  Circle through B with center A    
c: (x + 0.02)² + (y - 2.62)² = 3.73
             4
Point C

C = (5.18, 0.6)
             5
Point D

D = (3.4, 1.72)
             6
Circle d
  Circle through D with center C
d: (x - 5.18)² + (y - 0.6)² = 4.42
             7
Segment a
  Segment [A, C]
a = 5.58
             8
Point E
  Intersection point of c, a
E = (1.78, 1.92)
             9
Point F
  Intersection point of d, a
F = (3.22, 1.36)
            10
Line b
  Tangent to c through E
b: 1.8x - 0.7y = 1.86
            11
Line e
  Tangent to d through F
e: -1.96x + 0.76y = -5.27
            12
Angle β
  Angle between a, e
β = 90°
            13
Angle α
  Angle between b, a
α = 90°

And here is what the diagram looked like right after I created it:


Note that both the measured angles are 90°.  Now here's another view of the diagram, in which I've changed the sizes of the circles and positions of their centers by dragging on the appropriate points.



All the elements of the diagram updated themselves as I dragged the points, so that the constraints I'd created were always obeyed.

The thing that got me interested in the design of dynamic geometry environments was reading several papers written by H. S. M. Coxeter, arguably the greatest geometer of the 20th Century, and certainly the greatest champion of the visual aspect of mathematics in the anti-visual era of Nicolas Bourbaki. One of Coxeter's diagrams struck me as rather beautiful, a 3D rendering of 5 mutually-tangent spheres:

Five Spheres in Mutual Contact H. S. M. Coxeter
Journal for Geometry and Graphics Vol. 4, No. 2    
In this image, the 5 spheres have radii in the ratios 1, r, r2, r3, and r4. For Coxeter's 90th birthday, the Australian artist John Robinson gave him a sculpture of that model, in which the four largest spheres are made of wood and the smallest (just visible behind the others in the middle of the image) is made of steel.

Coxeter did a lot of work on sequences of mutually tangent circles (and spheres, and hyperspheres of arbitrary dimension.) He showed that if you create an unbounded sequence of circles such that every subsequence of 4 circles is mutually tangent, the result is that the sequence is self-similar under a transformation consisting of a scaling and a rotation, and the radii of the circles form a  Fibonacci series (and so the scaling is a geometric progression whose ratio approaches the Golden Ratio, τ + √τ where τ = ½(√5 + 1). See figure below.
Sequence of Mutually Tangent Circles H. S. M. Coxeter
"Loxodromic Sequences of Tangent Spheres." Aequationes Math. 1, 112-117, 1968.

That curve connecting the points of contact between the circles, as result of the Fibonacci series of radii, is  a self-similar equiangular spiral. Similarly, for spheres of dimension n, you can create a unique self-similar sequence of spheres where subsequences of n+2 spheres are mutually tangent and the points of contact are connected by a self-similar spiral in n dimensions. In the case of n=3 (the ordinary sphere), the curve is a concho-spiral: a spiral drawn on a cone.

All this got me to thinking about how a model of the sphere case, with the spiral somehow drawn in it, would look.  What I could visualize of it, based on playing with sketches and with diagrams drawn in a couple of dynamic geometry environments that I had easy access to, made me think that it could make a very beautiful model, if it were realized as transparent spheres with something like wire to show the spiral, and perhaps to decorate the spheres with curves that emphasize the contact points.  There are some interesting problems in making a model like that rigid enough so its parts don't shake, and the more I thought about them, the more it seemed reasonable to build the model in pieces from a computer file with a 3D printer.

I started evaluating all the software that I might be able to use to create the computer version of the model, and found that there was nothing that quite did the job.  None of the standard graphic programs I looked at could create the geometric constraints I needed, and while there are several engineering programs that might do the job with some kludging, they're all more expensive than I can afford for this project, considering that having the model printed commercially would cost several hundred dollars, and that getting it right might need several attempts. Looking at the math programs, especially geometry software, none of them except Mathematica could easily generate the right kind of files, and none of them were designed to easily do both 2D and 3D in the same diagram (so that I can decorate the spheres by plotting curves on their surfaces). Most of them don't do 3D at all, and of those that do, most of them work by switching between 2D and 3D modes.

At this point, I realized something about the implementation of all the geometry software I'd looked at. They all seemed to use standard coordinate geometry to describe the geometric primitives, so each primitive (point, line, curve, etc.) is described by some special data structure, and each constraint or other relation (e.g., testing for intersection of 2 primitives) is a special piece of code, and each kind of geometry (2D or 3D, Euclidean, Hyperbolic, or Spherical) requires different code for each of those relations. And I know of a better way, one I'd been reading about for the last couple of years: using Geometric Algebra.

I did some research on the web, and got a couple more books on the subject, and this is what I found out about the current state of Geometric Algebra (GA) and the software supporting it. There are open-source (gnu license) libraries for  building GA software on any graphics hardware that uses OpenGL, the standard 3D graphics library used on Mac OS and  iOS (iPhone and iPad); it's also available for Windows and Linux). There is a book describing the software and its use, Geometric Algebra For Computer Science, An Object Oriented Approach to Geometry, and the website at that link includes other software including a viewer for GA diagrams, and downloadable files of all the diagrams in the book. The library, as it turns out, includes a code generator that creates GA code that's almost as efficient as C code for the same purpose.


The book also describes techniques for using a 5 dimensional conformal (angle-preserving) GA space to represent a 3 dimensional geometry, whether it's Euclidean, Hyperbolic, or Spherical.  In that representation all points, lines, planes, and circles  are represented by the same basic type of object, and computing intersections, tangency, distance, and angles between objects all use the same kind of computation. 2D is automatically available in the same framework just by describing a surface (plane or spherical) in which the 2D objects are embedded. And all geometric transformations of these objects, translations, rotations, and reflections are represented by a single class of object, called a versor.


But wait, there's more.  GA supports an extension, Geometric Calculus, for computing derivatives and integrals of versors.  It turns out that, for instance, you can use it to compute incremental changes of a versor, giving a set of versors that can be used to create an animation of a geometric object.


As far as I can tell, none of the commercial geometric software uses GA, with the exception of an add-on package that someone has written for Mathematica.  I think using GA to implement the geometric representation of a dynamic geometry environment would be a big win in terms of elegance of design, maintainability, and ease of comprehension and change of the code. So I started looking at what it would take to build such a program on my Macintosh. And I'll relate some of what I found in the next part of this post, GA II: Tales of the Outer Product.



No comments: