DrGeo
Encyclopedia
DrGeo is a free software, created by Hilaire Fernandes for the Ofset. As its names suggests, it is a geometry software. It runs over GTK+
GTK+
GTK+ is a cross-platform widget toolkit for creating graphical user interfaces. It is licensed under the terms of the GNU LGPL, allowing both free and proprietary software to use it. It is one of the most popular toolkits for the X Window System, along with Qt.The name GTK+ originates from GTK;...

 interface.

Points

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

There is also the intersection
Line-line intersection
In Euclidean geometry, the intersection of a line and a line can be the empty set,a point, ora line. Distinguishing these cases, and finding the intersection point have use, for example, in computer graphics, motion planning, and collision detection....

 of 2 curves and the midpoint
Midpoint
The midpoint is the middle point of a line segment. It is equidistant from both endpoints.-Formulas:...

 of a segment
Line segment
In geometry, a line segment is a part of a line that is bounded by two end points, and contains every point on the line between its end points. Examples of line segments include the sides of a triangle or square. More generally, when the end points are both vertices of a polygon, the line segment...

.

Lines

DrGeo is equipped with the classic line
Line (geometry)
The notion of line or straight line was introduced by the ancient mathematicians to represent straight objects with negligible width and depth. Lines are an idealization of such objects...

, ray, segment
Line segment
In geometry, a line segment is a part of a line that is bounded by two end points, and contains every point on the line between its end points. Examples of line segments include the sides of a triangle or square. More generally, when the end points are both vertices of a polygon, the line segment...

 and vector.

There are also the circle (defined by 2 points) but also the less classic arc by three points. DrGeo can also construct polygons (given by points) and loci
Locus (mathematics)
In geometry, a locus is a collection of points which share a property. For example a circle may be defined as the locus of points in a plane at a fixed distance from a given point....

.

Transformations

Besides the parallel and perpendicular line through a point, DrGeo can apply to a point one of these transformations:
  1. reflexion
  2. symmetry
  3. translation
  4. rotation
  5. homothety

Macros

When some objects, called final depend from other objects, called initial it is possible to create a new transformation sending the initial objects to the final ones. This is a macro. It allows to add new objects to DrGeo like regular polygons or new transformations like circle inversion.

Scripting

DrGeo comes up with a script language, which is Scheme (a Lisp-like language).

Scheme object

It is possible also to create a Guile object, which is a number, but created with a script, written in the Scheme syntax. It can have one or several variables, which are chosen at the creation of the object, with mouse clicks. The names of the variables are a1, a2 etc. For example, if one wants the square of a number a1, the script


(define x (getValue a1))
(* x x)


creates a numeric object, whose value is the square of the first number. If now the first number is changed, the second one 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 , the script for the real part is (once one has selected a free point)


(define x (car (getCoordinates a1)))
(define y (cadr (getCoordinates a1)))
(- (* x x) (* y y))


and the script for the imaginary part (with the same point selected):


(define x (car (getCoordinates a1)))
(define y (cadr (getCoordinates a1)))
(* 2 x y)


getCoordinates a1 yields a list because a1 is a point, which has 2 coordinates. The CAR
Car and cdr
car and cdr are primitive operations on cons cells introduced in the Lisp programming language. A cons cell is composed of two pointers; the car operation extracts the first pointer, and the cdr operation extracts the second.Thus, the expression evaluates to x, and evaluates to...

 of this list is the first coordinate, which is the abscissa
Abscissa
In mathematics, abscissa refers to that element of an ordered pair which is plotted on the horizontal axis of a two-dimensional Cartesian coordinate system, as opposed to the ordinate...

, and the CADR
Car and cdr
car and cdr are primitive operations on cons cells introduced in the Lisp programming language. A cons cell is composed of two pointers; the car operation extracts the first pointer, and the cdr operation extracts the second.Thus, the expression evaluates to x, and evaluates to...

 of the list (the CAR
Car and cdr
car and cdr are primitive operations on cons cells introduced in the Lisp programming language. A cons cell is composed of two pointers; the car operation extracts the first pointer, and the cdr operation extracts the second.Thus, the expression evaluates to x, and evaluates to...

 of the CDR
Car and cdr
car and cdr are primitive operations on cons cells introduced in the Lisp programming language. A cons cell is composed of two pointers; the car operation extracts the first pointer, and the cdr operation extracts the second.Thus, the expression evaluates to x, and evaluates to...

) is the second coordinate.

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 and can be transformed into a macro.

Scheme-generated figure

The Guile
GNU Guile
GNU Guile is an interpreter/virtual machine for the Scheme programming language. It was first released in 1993. Guile includes modularized extensions for POSIX system calls, APL array functionality, and others packaged as an object library...

 object can only create one number, then if one wants to create a complex figure by a script, one has to write the script with a text editor, save it with the scm file extension, then make DrGeo evaluate the file.

Here is how DrGeo can create a Sierpinski triangle
Sierpinski triangle
The Sierpinski triangle , also called the Sierpinski gasket or the Sierpinski Sieve, is a fractal and attractive fixed set named after the Polish mathematician Wacław Sierpiński who described it in 1915. However, similar patterns appear already in the 13th-century Cosmati mosaics in the cathedral...

recursively:


(new-figure "Sierpinski")
(define (sierpin p1 p2 p3 n)

(let* (

(p4 (Point "" milieu-2pts p2 p1))
(p5 (Point "" milieu-2pts p2 p3))
(p6 (Point "" milieu-2pts p3 p1))

(q1 (Polygone "" npoints p1 p4 p6))
(q2 (Polygone "" npoints p2 p4 p5))
(q3 (Polygone "" npoints p3 p5 p6)))
(if (> n 1)
(begin
(envoi q1 masquer)
(envoi q2 masquer)
(envoi q3 masquer)))

(envoi p4 masquer)
(envoi p5 masquer)
(envoi p6 masquer)

(if (> n 0)
(begin
(sierpin p1 p4 p6 (- n 1))
(sierpin p2 p4 p5 (- n 1))
(sierpin p3 p5 p6 (- n 1))))))

(soit Point "A" free -3 -1)
(soit Point "B" free 3 -1)
(soit Point "C" free 0 3)

(sierpin A B C 5)
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK