Symbolic Geometry, Golden Spiral and Descartes-Geometry

Mathematica in Education
Vol.2 No.3
Spring 1993

by
Denis Monasse

Mathsoft Overseas, CP 641, 1211 Geneva 3 (Switzerland)

Introduction

Symbolic algebra becomes familiar to a growing population of students and professional users but symbolic geometry is just emerging from the shade. Descartes-Geometry has been developed to cover all the domains of Euclidean geometry from graphics art to CAD, desktop publishing and, of course, education. The present package deals with 2D geometry, the 3D part being still under testing.  It is written as a Mathematica  library program and can be considered as an advanced language built on Mathematica graphics functions. There are specific virtues to symbolic geometry: the calculations being exact, the figures are rigorous and theorems can be proven or, at least, suggested by the constructions. Another aspect is the generalization of functional programming which can define families of figures. The example chosen here to illustrate this technique is the golden spiral which is made of arcs of circles deduced from each other by a set of given rules. Fractal geometry is one among many other fields of application which can be contemplated: wall papers, mosaics, molecular modeling, integrated electronic circuits, etc.
Step by step, we shall show how to specify the relevant geometric objects. Geometric functions will then be coded to generate the spiral.

(* This code is used to produce Fig.1 and should not be reproduced inthe paper *)
o=POINT[0,0];
a1=POINT[1,0];
x1=POINT[0,1/2];
a2=POINT[0,(1+Sqrt[5])/2];
an=Angle[x1.a1,x1.a2];
x2=POINT[-(1+Sqrt[5])/4,0];
a3=POINT[-1-(1+Sqrt[5])/2,0];
x3=POINT[0,(-1-(1+Sqrt[5])/2)/2];
a4=POINT[0,-2-Sqrt[5]];
Draw[PointSize[.02],
     {a1,"A1",{-1,2}},{x1,"X1",{-2,1}},{a2,"A2",{-2,-1}},
     {x2,"X2",{1,-2}},{a3,"A3",{1,-2}},
     {x3,"X3",{-2,-1}},{a4,"A4",{-2,-1}},
     ARC[x1,a1,an],ARC[x2,a1,Pi],ARC[x3,a2,Pi],
     GrayLevel[.4],
     o.a1,o.x1,LINE[a1,a2],LINE[x2,x2>(a1.a2)],
     Interval->{{-3,2},{-5,2}}]

Definition of the Golden Spiral

The first steps of the construction of a golden spiral are illustrated in Fig.1. 
	a. A1 is the point of coordinates (1,0) and X1 the point of coordinates (0,1/2). The arc of circle of center X1 passing through A1 intersects the upper y-axis at A2. 
	b. The point X2 lies on the left hand part of the x-axis at a distance OA2/2 from the origin O. The half circle of center X2 starting at A1 intersects the left hand part of the x-axis at A3. That arc of circle passes through A2 but the property is not obvious. This is why the segment  A1A2 and its perpendicular bisector have been drawn to suggest a proof of the property. In passing, the figure drawn with the Descartes-Geometry command Draw repects all the peculiarities of the construct: this is the WYWIWYG (What You Want Is What You Get) aspect of Descartes-Geometry.  
	c. X3 on the lower part of the y-axis is at the distance OA3/2 from O. The half circle centered at X3 and starting at A2 cuts the y-axis at A4. The property noted in b is still valid: the new circle passes through A3.
	d. The process is then repeated indefinitely.

Fig.1 Starting the construction of a golden spiral

The golden spiral being defined by a recursive process, it will be drawn using:
i.  geometric objects : points, straight lines, circles, arcs of circle;
ii. geometric transformations : rotation and homothety;
iii.geometric functions to define families of elements,
iv.geometric arrays to construct the set of arcs of circle.

Getting started

The program Descartes-Geometry is a package of the Mathematica library and is called by the command

Get["Descartes`Geometry2D`"]

Geometric objects

There are seven basic geometric objects in Descartes-Geometry: ARC, CIRCLE, LINE, POINT,  POLYGON, STRAIGHT and VECTOR. For the present exercise, we shall consider ARC, CIRCLE,  POINT and STRAIGHT only.

Point

A point in the plane is characterized by its two coordinates and the head POINT. The origin, the points of coordinates (1,0) and (0,1/2) are respectively

o=POINT[0,0];
m=POINT[1,0];
p=POINT[0,1/2];

and they are represented and named using Draw

Draw[PointSize[.02],{o,"O"},{m,"M"},{p,"P"}]

The Mathematica directive PointSize has been added to improve the legibility of the points.

Straight line

Basic form

The basic form of a straight line is  STRAIGHT[u,v,w] where u, v, w are the coefficients of the equation of the straight line

u x + v y + w = 0

(x,y ) being the coordinates of a point on the straight line.

ox=STRAIGHT[0,1,0];
oy=STRAIGHT[1,0,0];

Using two points

It is very frequent to have a straight line defined by two points. The abbreviation for this function is ".". The line which joins M to P is

d=m.p

All the objects defined up to now can be plotted:

Draw[PointSize[.02],
     {o,"O",{1,1}},{m,"M"},{p,"P",{1,1}},
     ox,oy,d]

In order to avoid letters to be crossed by lines, the placing of the labels O and P in the representation of the points o and p has been explicitly specified with {1,1}.

Circle

Using center and point

The geometric object related to a circle has the head CIRCLE and the coordinates of the center and the radius as arguments. More often, the circle is defined by its center and a point, the abbreviated command is then "<" which reminds the compass. The circle c of center P passing through M is

c=p<m

Point on a circle

A point on a circle is defined by the command ParameterPoint whose first argument is the circle and the second argument is the angle made by a parallel to Ox through the center and the radius passing through the point. The point Q of parameter „/2 on c is

q=ParameterPoint[c,Pi/2]

There comes the golden ratio. The constructions on the circle c are represented by

Draw[PointSize[.02],
     {m,"M",{-3,0}},{p,"P"},{q,"Q",{-1,-2}},
     c]

Geometric Transformations

The needed geometric transformations are rotation and homothety.

Rotation

Using the command Rotate[POINT[a,b],t][obj], the geometric object obj is rotated about the point of coordinates (a, b) by the angle t. The rotation of the point M by „/2 about the origin is thus the point R defined by

mr=Rotate[o,Pi/2][m]

Homothety

The homothety of a geometric object obj is given by Zoom[POINT[a,b],r] [obj]. a and b are the coordinates of the homothety center and r is the homothety ratio. The point H homothetic of R with respect to the origin and in the ratio 1/2 is

mh=Zoom[o,1/2][mr]

The various transformations of m are represented by

Draw[PointSize[.02],{m,"M"},{mr,"R"},{mh,"H"},
     ox,oy]

Composition of transformations

We have seen that the centers X of the arcs of the golden spiral were deduced from the points A by composing a rotation of center o and angle „/2 with a homothety of center o and ratio 1/2. The global operator which composes rotation and homothety is ZR, obtained with the Mathematica command Composition:

ZR=Composition[Zoom[o,1/2],Rotate[o,Pi/2]];
Draw[PointSize[.02],{o,"O"},{m,"M"},{ZR[m],"X"},
     ox,oy]

Geometric functions

Until now, we had to deal with discrete objects. In the definition of the golden spiral, the points A, the centers X, the arcs of circle belong to families. It is then appropriate to use the concept of geometric function.

A point function is a point whose coordinates depend on one or more variables. For instance, the relation which defines the centers X can be written

x[n_]:=x[n]=ZR[a[n]]

where n is an integer variable.

In a circle function, center and point may depend on variables. We shall have to use

c[n_]:=c[n]=x[n-1]<a[n-2]

A geometric function may also involve a command using other geometric functions. The points A are defined by

a[n_]:=a[n]=N/@ParameterPoint[c[n],(n-1)*Pi/2]

The calculations are speeded up by forcing the functions to remember their values calculated at an earlier iteration and by evaluating a[n] numerically. The definition of the geometric functions has to be completed by the initial conditions

a[0]=a[1]=POINT[1,0];

Geometric arrays

In Descartes-Geometry, the concept of list generation based on the Mathematica command Array has been extended to geometric arrays in the command ArrayG. In Array, the arguments are an operator and the number of elements of the list. In ArrayG, the arguments are also an operator, the number of elements in the list and, in addition, geometric functions that the operator acts upon.

The half circles of the golden spiral can be created with ArrayG and the operator Arc. The arguments of Arc are the center of the arc, the starting point and the length of the arc. In addition, the end of the arc may be named say z. Here, it is convenient to redefine a new family of centers Y such that

y[n_]:=x[n+1]

The starting points are the elements of the family a[n]. All the angles of rotation t are equal to „ so that we create the constant function

t[n_]=Pi;

The number of elements of the geometric array is the sixth argument of ArrayG. To make sure that  we get what we want, let us try to create the first half circle:

ArrayG[Arc,y,a,t,z,1]

In the case of the operator Arc, ArrayG produces a grahics object and, by default, displays it. For most operators however, the output of ArrayG is a list whose first element is a Graphics object and second element a list of substitution rules defining the generated objects  analytically so that the way is paved for further graphical or analytical manipulations.

We can now proceed with an arbitrary number of arcs, say 7, and we inhibit the naming of the arcs:

p1=ArrayG[Arc,y,a,t,z,7,Named->False]

The two end arcs have now to be added. When there is no regular law to construct a figure, it is still possible to define geometric arrays by giving the arguments in matrix form. Here, the head of the command is Arc and each row contains the center, the starting point, the length and the name of the end points of a given arc.

p2=Arc[{{x[1],a[1],Angle[a[1].x[1],oy],"",""},
        {x[9],a[8],Angle[oy,x[9].a[9]],"",""}}]

The angle is defined as the angle between the normal vectors of the straight lines and is therefore uniquely defined in magnitude and in sign.

Show[p1,p2]

This is the end of the exercise.

Conclusion

The golden spiral has been used to illustrate the functionalities of Descartes-Geometry namely the construction of elementary figures and their assembly in an array defined by geometric functions. This example gives just a sampling of the facilities provided by Descartes-Geometry which contains more than hundred functions. The program is actually the symbolic image of a course of analytic geometry taught in high schools and colleges and updated with various objects such as the splines which are so common in graphical applications.

The program Descartes-Geometry is commercially available from:

Mathsoft Overseas, cp 641, 1211 Geneva 3 (Switzerland). 
Tel: 41 22 346 52 60. Fax: 41 22 346 59 39