# DrGeo

Original author(s) Hilaire Fernandes December 31, 1996 14.07 / June 25, 2014; 2 months ago Active Pharo, Smalltalk Linux, Mac OS X, Windows, Android, iOS, Sugar Interactive geometry software GPL drgeo.eu

Dr. Geo is a free (under GNU GPL license) software, created by Hilaire Fernandes. As its name suggests, it is an interactive geometry software. It runs over a Morphic graphic system (which means that it runs on Mac OS, Windows, Linux, Android and iOS). Current version of Dr. Geo is also called Dr. Geo II. Historically Dr. Geo was developed in C++ and Dr. Geo II is a complete rewrite using Pharo that happened in 2005. This article refers to the most recent version.

## Objects

Dr. Geo manipulates different kinds of objects such as points, lines, circles, block of code.

### Points

Dr. Geo has two kinds of points: a free point, which can be moved with the mouse (but may be attached to a curve) and a point given by its coordinates.

Points can also be created as the intersection of 2 curves or as the midpoint of a segment.

### Lines

Dr. Geo is equipped with the classic line, ray, segment and vector.

Other curvilinear objects include circles (defined by 2 points, a center and segment or a radius), arcs (defined by three points or center and angle), polygons (regular or not, defined by end points), and loci.

### Transformations

Besides the parallel and perpendicular line through a point, Dr. Geo can apply to a point or a line one of these transformations:

1. reflexion
2. symmetry
3. translation
4. rotation
5. homothety

### Macro-construction

When some objects, called final depend on other objects, called initial, it is possible to create a complex construction deducing the final objects from the user-given initial objects. This is a macro-construction, a graph of interdependent objects. It allows to add new objects to Dr. Geo: new transformations like circle inversion, tedious constructions involving a lot of intermediate objects or constructions involving script (also named macro-script).

## Programming

Dr. Geo source code is Smalltalk. It is the language used for user programming: to extend Dr. Geo with arbitrary computing operations (Smalltalk script) and to define a geometric sketch entirely with programming instructions (Smalltalk sketch).

### Smalltalk script

A script is a computing object plugged in a Dr. Geo canvas, it is executed each time the whole canvas is recomputed. It comes with zero, one or several arguments, which are chosen in the canvas at the use time of the script, with mouse clicks. The names of the arguments are defined by the user. For example, if one wants the square of a number myNumber, the script

square: myNumber
"returns the square of a number"
^ myNumber valueItem squared


creates a numeric object, whose value is the square of the argument number object. Whenever the first number is changed, the script returned value changes too.

If now one wants to implement the square of a complex number, one has to create 2 numeric values, one for the real part, and the other one for the imaginary part. As $(x+iy)^2=x^2-y^2+i(2xy)$, the script for the real part is:

realPart: complex
"Compute the square of the real part of a complex number"
^ complex point x squared - complex point y squared.


and the script for the imaginary part:

imaginaryPart: complex
"Compute the square of the imaginary part of a complex number"
^ 2 * complex point x * complex point y.


Argument complex is a point object in the canvas, to retrieve its coordinates, the message #point is sent to him. Messages #x and #y are sent to point to retrieve respectively abscissa and ordinate.

Once this is done, it remains only to create a point which coordinates are the two numbers created by scripts, and a transformation is defined; it implements the function $\C \rightarrow \C, z \mapsto z^2$ and can be transformed into a macro.

### Smalltalk sketch

Dr. Geo Smalltalk sketches – (DSS) – are sketches entirely defined in the Smalltalk language. This is not about constructing a sketch with the Dr. Geo graphical interface, but about describing a sketch with the Smalltalk language. A programming interface with an easy and light syntax is provided.

Here is how Dr. Geo can create a Sierpinski triangle recursively:

| triangle c |
triangle := [].
c := DrGeoCanvas new.
triangle := [:s1 :s2 :s3 :n |
c segment: s1 to: s2;
segment: s2 to: s3;
segment: s3 to: s1.
n > 0 ifTrue:
[triangle
value: s1
value: (c middleOf: s1 and: s2) hide
value: (c middleOf: s1 and: s3) hide
value: n - 1.
triangle
value: (c middleOf: s1 and: s2) hide
value: s2
value: (c middleOf: s2 and: s3) hide
value: n - 1.
triangle
value: (c middleOf: s1 and: s3) hide
value: (c middleOf: s2 and: s3) hide
value: s3
value: n - 1]].

triangle
value: (c point: 0 @ 3)
value: (c point: 4 @ -3)
value: (c point: -4 @ -3)
value: 3.