Interactive geometry

Bruno Autin

CERN honorary member

Introduction

In addition to the animations of the documentation, the package GeometricaPlus deals with two types of interactivity. The first one concerns libraries of geometrical objects, namely conics, quadrics, parametric curves and surfaces and platonic solids. For instance, by typing a statement such as PlatonicSolid[x], the user triggers the display of a menu containing the five platonic solids and clicking a window will transfer the selected solid to the dynamic variable x. For intersections, the two curves are displayed in a window and cursors are provided to displace a point on each curve. The points are moved until they  approximately coincide close to an intersection. Then, by clicking a button Solve, the numerical coordinates of the intersection are calculated and the process can be repeated for any other intersection. In all the interactive applications, the dynamic results can be used for further treatment such as drawing or geometrical transformation.

Creating animations

Two functions in GeometricaPlus, Arc and Strip, are designed to generate curves and surfaces respectively.

A special swing

The cissoid can be defined as the curve described by the vertex of a parabola Q rolling on another fixed parabola P. The parameter v is that of a point A of P. The construction is shown for the parabola P of equation (y^2)-2x=0. Q is obtained by symmetry of P with respect to the tangent t at P in A. The vertices O of P and B of Q are symmetric with respect to t. The cissoid is described by the point C symmetric of the vertex O of P with respect to t. Its parametric form is obtained using the function ToPPoint.

Needs["Geometrica`"]

Clear[v]
p=CConic[0,0,-1,1,0,0];
tg=ELine[p,v];
o=CPoint[0,0];
c=Symmetry[o,tg];
ci1=ToPPoint[c,v]

To animate the construction of the cissoid, it is necessary to define the contour of the space spanned by the parabola Q during its rotation. That contour is defined by the end points e of Q.

e=Symmetry[Pointer[p,{-1,1}Pi],tg];
ep=ToPPoint[e,v];
g1=Draw[Blue,p,o,Gray,ci1,ep]

The animation can now be coded.

Manipulate[
a=Pointer[p,u];
t=ELine[p,u];
q=Symmetry[p,t];
b=Vertices[q]; 
ar=Arc[ci1,-π,u];
g2=Draw[Blue,t,Green,q,Red,ar,b];
Show[g1,g2],
{u,-3,3}]

Animations have been developed for other problems such as the normals from a point to a conic, the position of a Serret-Frenet system along a 2D or 3D curve, parallel curves and surfaces at fixed or variable distance, pipes of fixed or variable radius or generation of ruled surfaces,

Generating surfaces with the Strip function

The surface investigated here uses a Viviani’s window, a curve which is the intersection of a cylinder of revolution with a sphere. The cylinder is tangent to the sphere and passes through its center.

vi=VivianiWindow[2];
sp=ESphere[2];
cy=ECylinder[ECircle[CPoint[1,0],1],CPoint[0,0,1]];
Draw3D[AbsoluteThickness[3],Green,vi,Opacity[.5],Paint[{sp,cy},{Blue,Red}]]

The surface that will be studied is a knot formed by a cylinder K of base is a Viviani’s window and generators parallel to (-.3,0,0).

v=VivianiWindow[];
k=ECylinder[v,CPoint[-.3,0,0]]/.(50->100);
Draw3D@Paint[k,Yellow,Green]

That knot can be generated dynamically using the function Strip. To stabilize the diagram, the entire knot is drawn first.

g0=Draw3D[GrayLevel[.9],k];
Manipulate[s=Strip[k,{-π,u},{0,1}];
g=Draw3D[Paint[s]];
Show[g,g0],
{u,-π,π}]

Geometry libraries

The animations of the previous section are useful to get an in-depth view of the GeometricaPlus functions and invite the user to write his own animations using non Mathematica functions. However, they use static functions. The access to libraries calls functions in which interactivity is built in the GeometricaPlus code.

Quadrics

If ellipse, parabola and hyperbola belong to the common vocabulary, to remember the name of the various surfaces whose equation is second degree in at least one of the coordinates is not as easy. A catalog of that surfaces, called quadrics, has thus been created in GeometricaPlus. It is accessed using the function Quadric[x] where x is a symbol. x is not an input variable but the name given to the dynamic output of Quadrics.

Needs["Geometrica`"]

Clear@x
Quadric[x]

Then, typing x returns the expression of the sphere

x

One can now manipulate x at will by transfering its value to a local variable s.

s=x

As an example of local manipulation, the sphere shall be transformed into a cylinder of revolution. The ten coordinates of the quadric are kept in list ls. The second coordinate is replaced by 0 and the function CQuadric applied to the new list rs so that it detects the new type of quadric.

ls=List@@s;
rs=ReplacePart[ls,2->0];
cy=CQuadric@@rs

The sphere and cylinder can be represented together.

Draw3D[Paint[x,Red],Opacity[.5],Paint[cy,Green]]

If we select a new quadric in the menu, say a hyperboloid of one sheet, and re-applies the previous statement, one gets

Draw3D[Paint[x,Red],Opacity[.5],Paint[cy,Green]]

Parametric curves and surfaces

When the argument of PPoint is a symbol y, a pop-up menu is displayed and y is the chosen curve or surface. y, like x for quadrics, is a dynamic variable updated at each selection of curve or surface. In this example, a limaçon and a trochoid are plotted in the same graph. First, one evaluates the two following statements.

Clear@y
PPoint[y]

Then a menu pops-up and one clicks the Cycloid window. A tick appears in the left hand column. The variable y contains the representation of the cycloid which is stored in cy.

cy=y

Returning to the menu, one clicks a black arrow until the Trochoid window appears. Clicking the Trochoid window updates y which contains now the expression of the trochoid and y is stored in tr.

tr=y

It remains to draw the two curves in the same graph.

Draw[Blue,cy,Red,tr]

Platonic solids

The number of sides of a regular polygon is not limited but there are only five solids which have congruent faces. That solids are the Platonic solids and it is convenient to pick them up in a library in case one does not remember the type of Platonic solid to call. The principle is exactly the same as for the other libraries. The statement is

Clear@z
PlatonicSolid[z]

To see the configuration of the cube and the sphere, one first stores z in local variable cu.

cu=z;

Then, returning to the quadrics library, one cliks the Sphere window, stores x in sp and draw the cube in a semi-transparent sphere which turns out to be  circumscribed to the cube, in contrast with Mathematica platonic solids whose edges have unity length.

sp=x
CEllipsoid[1,1,1,0,0,0,0,0,0,-1];
Draw3D[Paint[cu],Opacity[.3],Paint[sp]]

Dynamic intersections

Two parametric curves (Subscript[C, 1]) and (Subscript[C, 2]) can be intersected using the “static” statement

Intersections[c1,c2]

The method consists of replacing the curves by polygonal lines. All the vertices lie on the curve. The PRange option provides the end parameters and thus the end points, and the number of definition points n. The polygonal line has thus n-1 sides. As the intersection of two point segments is coded, the intersection of two polygonal lines can be found. Though useful in a first approach, that technique is less precise than the numerical algorithms coded in Mathematica. Moreover, the intersecting point is just one characteristic of the intersection. One may wish to determine the local properties of each curve at the intersection such as tangent, normal or curvature. For that reason, the complete information is provided by the values of the parameters of each curve at the intersection. Therefore, it is relevant to have another function which returns the precise parameterss at the intersection.
The concept of dynamic intersections consists of providing the user with a graph of the two curves and with cursors which displace the point bound to each curve. The user manipulates the two points until they coincide near the wanted intersection. That almost common position defines a first approximation to the precise solution obtained by clicking a button “Solve”. If the curves have several intersections, the operation can be repeated for any intersection and the intersection parameters are returned in a dynamic list. The example deals with the intersection of an epitrochoid ep with a spiral sp. 
The upper cursor displaces the blue point of the spiral and the lower cursor displaces the red point of the epitrochoid. After choosing the point of coincidence of the two cursors, one presses the button Solve and the parameters of intersection are displayed. The first parameter applies to the spiral and the second one to the epitrochoid.

ep=Epitrochoid[];
sp=PPoint[(# /3)Cos[#]&,(#/3) Sin[#]&,PRange->{0,10,50}];
DynamicIntersection[sp,ep,xes]

The manipulation can be repeated for all intersections and xes contains all the couples of parameters at each intersection in a list. Transposing xes collects the parameters of the spiral and of the epitrochoid in two separate lists xs and xe.

{xs,xe}=Transpose@xes

One can first check the quality of the calculation by comparing the points on the two curves

x1=Pointer[sp,xs]
x2=Pointer[ep,xe]

The lists are the same at least within a five decimal precision. Let us find now the Serret-Frenet local frames of each curve at the four intersections.

f1=Frenet[sp,xs];
{ta1,no1}=Transpose[{Tangent,Normal}/.#&/@f1];
f2=Frenet[ep,xe];
{ta2,no2}=Transpose[{Tangent,Normal}/.#&/@f2];
Draw[Black,sp,White,ep,Blue,x1,Arrow@ta1,Arrow@no1,Red,x2,Arrow@ta2,Arrow@no2,Background->Gray]

Conclusion

Interactivity brings a new realm to geometry. It provides a game environment to treat the problems and animations are quickly prepared in many cases as it was shown  for kinematic curves. The access to data bases is straightforward and the data can be exploited locally for further applications. Problems such as complicated intersections can be given a simple configuration and solved with a satisfactory precision. 3D applications are also within the access range of interactivity. The function Strip is to surfaces what Arc is to curves. However, manipulating surfaces may lead to excessive computing times.

Acknowledgments

I am grateful to Luc Barthelet who suggested the syntax of the dynamic functions.