EUKLEIDES

Eukleides is a Euclidean geometry drawing language. Two softwares are related to it. First, eukleides, a compiler which allows to typeset geometric figures within a (La)TeX document. This program is also useful to convert such figures in EPS format or (using pstoedit) in various other vector graphic formats. Second, xeukleides, an X-Window front-end which makes possible to create interactive geometric figures. This program is also useful to edit and tune some Eukleides code.

This is edition 2.2 of Eukleides's documentation.

Tutorial
********

In this chapter, we'll see some possible usages of eukleides, of the shell scripts euk2eps and euk2edit, and of xeukleides.

Drawing a triangle
==================

The language Eukleides has been designed in order to be close to the traditional language of Euclidean geometry. For instance, to draw a triangle, you just have to type:

     A B C triangle
     draw(A, B, C)

If you save these two lines in a file, say triangle.euk, you can now try this:

     $ eukleides triangle.euk

and you'll get the following output:

     % Generated by eukleides *.*.*
     \psset{linecolor=black, linewidth=.5pt, arrowsize=2pt 4}
     \psset{unit=1.0000cm}
     \pspicture*(-2.0000,-2.0000)(8.0000,6.0000)
     \pspolygon(0.0000,0.0000)(6.0000,0.0000)(2.2500,3.6742)
     \endpspicture

The lines above are PSTricks commands, they can be inserted verbatim in a (La)TeX source file (remember to first load the PSTricks package).

The resulting document will contain a figure representing a scalene triangle.

To see this triangle there is a shorter way: the shell script euk2eps generates a file in EPS format, which can be viewed with GhostView. Furthermore, the script euk2edit (which uses pstoedit) allows to convert the figure in a vector graphic format, like the ones used for Xfig or Sketch. For instance, in order to edit the figure with Sketch, type:

     $ euk2edit triangle.euk sk

It is usually more convenient to have a single file containing both text and illustrations. This is possible with eukleides, using the -f option and the special comments %--eukleides and %--end. For instance, if you type the following lines with your favorite text editor:

     \input pstricks
     This is a scalene triangle:\par
     %--eukleides
     A B C triangle
     draw(A, B, C)
     %--end
     \bye

and save this as triangle.etex, you can get a DVI file with:

     $ eukleides -f triangle.etex > triangle.tex && tex triangle.tex

Then, you may convert this file in PostScript format and view it with:

     $ dvips -o triangle.ps triangle && gv triangle.ps

More about triangles
====================

The X-window program xeukleides is a graphical front-end for the language Eukleides. It has two modes: an editing mode and a viewing mode. To start xeukleides, editing the file created in the first section, type:

     $ xeukleides triangle.euk

To start in viewing mode instead, add the -V option. You can switch between modes, by pressing the escape key. Since the editing mode is based on the GTK+ text editor widget, xeukleides has all the features of a simple text editor. Here is a list of some useful shortcuts:

  Alt-F   One word forward.
  Alt-B   One word backward.
  Alt-D   Delete one word forward.
  Ctrl-W   Delete one word backward.
  Ctrl-U   Delete current line.
  Ctrl-K   Delete to end of line.
  Ctrl-X   Cut selection to clipboard.
  Ctrl-C   Copy selection to clipboard.
  Ctrl-P   Paste selection from clipboard.

The drawn triangle is an optimal scalene triangle (i.e. it is an acute triangle which shape is as far as possible from the shape of right or isosceles triangles). You may want to draw another kind of triangle. The language Eukleides provides a wide variety of ways to define triangles. See what happens if you replace the triangle command with right, isosceles or equilateral.

These commands can take some optional parameters. For instance:

     A B C triangle(6, 5, 4)

defines a triangle ABC such that AB = 6 cm, BC = 5 cm and AC = 4 cm.

Another example:

     A B C isosceles(6, 50:)

defines an isosceles triangle ABC such that AB = 6 cm and the angles at vertices A and B equal 50 degrees.

A property of parallelograms
============================

We are now going to study the way to create a figure representing a parallelogram, its center and diagonals. Furthermore the figure will contain marks showing that the center is also midpoint of the diagonals.

First we need to define the parallelogram and its center:

     A B C D parallelogram
     O = barycenter(A, B, C, D)

Then, we can draw them:

     draw(A, B, C, D) ; draw(O)

and the diagonals:

     draw(segment(A, C), dotted)
     draw(segment(B, D), dotted)

Finally, we draw the marks on the diagonals. Double dashes:

     mark(segment(O, A), double)
     mark(segment(O, C), double)

and crosses:

     mark(segment(O, B), cross)
     mark(segment(O, D), cross)

The theorem of Thales
=====================

In this last section, we'll see an example of interactive geometric figure for xeukleides. It shows that any triangle inscribed in a semicircle has a right angle. With such a figure, it'll be possible to move the vertex corresponding to the right angle on the semicircle by pressing the left or right arrow keys. First, we define point A, point B and circle C of diameter AB, with the following commands:

     A = point(0, 0) ; B = point(6, 0)
     C = circle(A, B)

Points A and B are here defined using coordinates. When nothing is specified, the figure is drawn in a frame such that the lower left point has coordinates (-2;-2) and the upper right (8;6). After this, we define an interactive variable t:

     t interactive(60, -2, 0, 180, "A", right)

This means that the initial value of t is 60, the lower bound 0, the upper bound 180. In viewing mode, every time the right (left) arrow key will be pressed, -2 will be added (subtracted) to this variable. Instead of right, it is also possible to use keyword up, in order to bind the variable to the up and down arrow keys. Last, "A" indicates which state corresponds to the variable. When viewing mode is started, the program is in state A.  There are 26 available states, from A to Z, hence one can define 52 interactive variables for the same figure. To switch from a state to another, one just has to hit the corresponding key. We now define a point M on circle C with:

     M = point(C, t:)

The second parameter is followed by a colon to indicate that it's an angular parameter. Variable t corresponds to the argument (in degrees) of point M in respect of the center of C. Then, we draw the upper half of circle C and triangle ABM, which has a right angle at vertex M.

     color(lightgray)
     draw(C, 0:, 180:)
     color(black)
     draw(A, B, M)

Last, we draw the usual right angle mark:

     mark(A, M, B, right)

It is possible to capture the actual value of variable t by pressing the F1 key. In this case, the initial value of t in the source code is replaced by the actual value and the program switches to editing mode. All source codes written for xeukleides can be used with eukleides (the interactive variables are simply set to their initial values).

Reference
*********

This chapter is a comprehensive reference manual for the language Eukleides.

Syntax
======

A Eukleides source file can contain:

  * Comments, i.e. all characters after a `%' to end of line.

  * Simple assignments, i.e. a variable name followed by `=' and an expression.

  * Multiple assignments, i.e. a space delimited sequence of variable names, followed (without `=') by a multiple assignment command (triangle assignment, polygon assignment, intersection assignment ...).

  * Interactive assignments, i.e. a variable name followed by `=' (optionally) and the keyword interactive with some parameters.

  * Graphical commands, i.e. parameter setting commands, drawing commands or trace commands.

Variable names are case sensitive, the first character has to be a letter or an underscore character, further ones can be letters, digits, underscores or single quote characters. Variables can store various objects: number, vector, line, segment, circle, conic curve. A line of the source file can contain more than one assignment or command. (In this case they must be separated by semicolons. A semicolon at the end of the line is allowed but not necessary.)

We'll use the following notations to describe the parameters in a command:

  * x, y, z : number.

  * a, b : angular parameter.

  * A, B, C, D, E, F, G : point.

  * u, v : vector.

  * l : line.

  * s : segment.

  * c : circle.

  * cc : conic curve.

  * str : string.

  * f : flag.

An angular parameter is a number valued expression followed by `:' (degrees) or `<' (radians). A string is any single line text enclosed in double quotes or dollar symbols (which should be used for `"$' and `$"').

We'll use square brackets to indicate optional parameters.

Numbers
=======

To compute usual arithmetical operations, use the symbols: (, ), +, -, *, /, ^ (for exponentiation).

There's a C-like ternary test operator using the symbols ? and |. To perform a test one may use the following comparison and logical operators: ==, !=, <=, >=, <, >, and, or, not.

The available numerical functions are: abs(x), min(x), max(x), clamp(x, y, z) (which returns x if y<=x<=z, y if x<y, z if x>z), sign(x), (which returns -1 if x<0, 0 if x=0, 1 if x>0), ceil(x), floor(x), round(x), sqrt(x), exp(x), ln(x), sin(x), cos(x), tan(x), asin(x), acos(x), atan(x), deg(x) (to convert radians in degrees), rad(x) (to convert degrees in radians).

There is one constant: pi.

Next, the following number valued functions are also available:

  * abscissa(A) or abscissa(u)

  * ordinate(A) or ordinate(u)

  * distance(A, B) or distance(A, l)

  * length(u) or length(s)

  * radius(c)

  * major(cc)
     Half of the major axis if cc is an ellipse; half of the real axis if cc is an hyperbola; semifocal chord if cc is a parabola.

  * minor(cc)
     Half of the minor axis if cc is an ellipse; half of the imaginary axis if cc is an hyperbola; zero if cc is a parabola.

  * eccentricity(cc)

  * arg(c, A)
 Argument of point A in respect of circle c. If A isn't on c, arg returns the argument of the image of A by a projection on c in the direction of its center.

  * arg(cc, A)
     Argument of point A in respect of the internal parametric representation of cc. If A isn't on cc, arg returns the argument of the image of A by a projection on cc. The direction of the projection is the one of the principal axis if cc is a parabola, of the center if cc is an ellipse, of the major axis if cc is an hyperbola.

  * height(A, B, C)
     Distance between point B and line AC.

Last, there are all the angle measure functions. The result is in degrees. Eukleides handles directed angles, hence angle returns a signed number greater than -180 degrees and smaller than or equal to 180 degrees.

  * angle(u) or angle(l) or angle(s)
     Polar angle of the object.

  * angle(cc)
     Polar angle of the principal axis of conic curve cc.

  * angle(u, v)
     Measure of the angle between vector u and vector v.

  * angle(A, B, C)
     Measure of the angle under ABC. (The angle under ABC is the angular sector in which one can draw counterclockwise an arc of center B from point A to line BC.  Therefore the angle under ABC is different from the angle under CBA.)

Vectors
=======

To compute usual vectorial operations, use the symbols: (, ), +, -, * (multiplication by a number or scalar product of two vectors), / (division by a number).

Here are all the vector valued functions:

  * vector(x, y)
     Vector of abscissa x and ordinate y.

  * vector(x, a)
     Vector of length x and argument a.

  * vector(A, B)
     Vector from point A to point B.

  * vector(l)
     Unit length vector with same direction than line l.

  * vector(s)
     Vector from begin of segment s to end of s.

  * rotation(u, a)

Points
======

Here are all the point valued functions:

  * point(x, y)
     Point of abscissa x and ordinate y.

  * point(x, a)
     Point of radial coordinate x and polar angle a.

  * point(l, x)
     Point of abscissa x on the graduated line l. (With Eukleides, lines have an implicit orientation.)

  * point(s, x)
     Point of abscissa x on the graduated line containing segment s. (The origin is set to the begin of s. Like lines, segments have an implicit orientation.)

  * point(c, a)
     Point of argument a (in degrees) on circle c.

  * point(cc, x)
     Point on conic curve cc. Number x is the argument for the internal parametric representation of cc. For parabolas, the representation is based on square function; for ellipses, on cosine and sine; for hyperbolas, on cosecant and tangent.

  * barycenter(A [, x], B [, y])
     Barycenter of A and B with coefficient x and y (default: 1 and 1). The syntax is similar for 3 or 4 points.

  * intersection(l, l')
     Intersection point of lines l and l'.

  * abscissa(l, x)
     Point of abscissa x on line l.

  * ordinate(l, y)
     Point of ordinate y on line l.

  * midpoint(s)

  * begin(s)

  * end(s)

  * center(c)

  * center(cc)
     If cc is a parabola, the result is its vertex.

  * orthocenter(A, B, C)
     Orthocenter of triangle ABC.

  * translation(A, u)

  * reflection(A, l)

  * rotation(A, B [, a])
     Rotation of center B and angle a (default: 180 degrees).

  * homothecy(A, B, x)
     Homothecy, i.e. expansion or dilation, of center B and ratio x.

  * projection(A, l [, l'])
     Projection of point A on line l in direction of line l' (default: perpendicular to line l).

Lines
=====

With Eukleides, the internal representation of lines is based on an abscissa, an ordinate and a polar angle. Therefore lines have an implicit orientation. Here are all the line valued functions:

  * line(A, B)

  * line(A, u)

  * line(s)

  * line(A, a)
     Line of polar angle a, containing point A.

  * line(c, a)
     Tangent line of circle c at point of argument a (in respect of the center of c).

  * line(cc, x)
     Tangent line of cc at point of argument x (in respect of the internal parametric representation). For parabolas, the representation is based on square function; for ellipses, on cosine and sine; for hyperbolas, on cosecant and tangent.

  * parallel(l, A) or parallel(s, A)

  * perpendicular(l, A) or perpendicular(s, A)

  * bisector(s)
     Perpendicular bisector of segment s.

  * bisector(A, B, C)
     Bisector of angle under ABC.

  * bisector(l, l')
     Bisector of the sharp angle formed by l and l'.

  * altitude(A, B, C)
     Altitude of triangle ABC containing vertex A.

  * median(A, B, C)
     Median of triangle ABC containing vertex A.

  * translation(l, u)

  * reflection(l, l')
     Reflection in respect of line l'.

  * rotation(l, A [, a])
     Rotation of center A and angle a (default: 180 degrees).

  * homothecy(l, A, x)
     Homothecy, i.e. expansion or dilation, of center A and ratio x.

Segments
========

With Eukleides, the internal representation of segments is based on a begin point and an end point. Therefore segments have an implicit orientation. Here are all the segment valued functions:

  * segment(A, B)

  * segment(A, u)

  * segment(A, x, a)
     Segment of length x and polar angle a, beginning with A.

  * segment(c, a)
     Segment from center of circle c to point of argument a (in respect of the center of c).

  * translation(s, u)

  * reflection(s, l)

  * rotation(s, A [, a])
     Rotation of center A and angle a (default: 180 degrees).

  * homothecy(s, A, x)
     Homothecy, i.e. expansion or dilation, of center A and ratio x.

Circles
=======

Here are all the circle valued functions:

  * circle(A, B)
     Circle of diameter AB.

  * circle(A, B, C)
     Circumcircle of triangle ABC.

  * circle(A, x)
     Circle of center A and radius x.

  * incircle(A, B, C)

  * translation(c, u)

  * reflection(c, l)

  * rotation(c, A [, a])
     Rotation of center A and angle a (default: 180 degrees).

  * homothecy(c, A, x)
     Homothecy, i.e. expansion or dilation, of center A and ratio x.

There are also the two following multiple assignments:

  * A B intersection(l, c)

  * A B intersection(c, c')

If the two object are tangent, the two variables will be set to the same point.

Conics
======

Here are all the conic curves valued functions:

  * conic(A, l, x)
     Conic curve of focus A, directrix l and eccentricity x.

  * conic(A, B, x)
     Conic curve of foci A and B. Number x is the half of the distance between the vertices (i.e. major axis for ellipses, or real axis for hyperbolas).

  * parabola(A, l)
     Parabola of focus A and directrix l.

  * parabola(A, x, a)
     Parabola of center A, such that x equals the semifocal chord and a the measure of the angle between the principal axis and the horizontal direction.

  * ellipse(A, x, y, a)
     Ellipse of center A, such that x equals the half of the major axis, y the half of the minor axis and a the polar angle of the principal axis.

  * hyperbola(A, x, y, a)
     Hyperbola of center A, such that x equals the half of the real axis, y the half of the imaginary axis and a the polar angle of the principal axis.

  * translation(cc, u)

  * reflection(cc, l)

  * rotation(cc, A [, a])
     Rotation of center A and angle a (default: 180 degrees).

  * homothecy(cc, A, x)
     Homothecy, i.e. expansion or dilation, of center A and ratio x.

There are also the three following multiple assignments:

  * A B foci(cc)

  * A B vertices(cc)

  * A B intersection(l, cc)

Triangles
=========

A triangle assignment is a list of 3 variable names followed by the word triangle, right, isosceles or equilateral and some optional parameters. If the first variable is already defined as a point, the triangle is constructed from this point. If not, the point is set to origin. The optional parameter b is the polar angle of segment AB (default: 0 degrees). Here are all the ways to define a triangle when the second variable is not already defined as a point:

  * A B C triangle[(x [, b])]
     Defines a scalene triangle with AB = x (default: 6). The triangle is an optimal scalene triangle (i.e. an acute triangle which shape is as far as possible from the shape of right or isosceles triangles).

  * A B C
     triangle(x, y, z [, b])

     Defines a scalene triangle with AB = x, BC = y and  AC = z.

  * A B C
     triangle(x, a, a' [, b])

     Defines a scalene triangle with AB = x, measure of the angle under BAC equals a, measure of the angle under CBA equals a'.

  * A B C
     right[(x, y [, a])]

     Defines a right triangle (right angle in A) with AB = x and AC = y (default: 6 and 4.5).

  * A B C right(x, a [, b])
     Defines a right triangle (right angle in B) with AB = x and measure of the angle under BAC equals a.

  * A B C
     isosceles[(x, a [, b])]

     Defines an isosceles triangle with AB = x and measure of the angle under BAC and angle under CBA equal a (default: 6 and 39 degrees).

  * A B C isosceles(x, y [,
     b])

     Defines an isosceles triangle with AB = x and AC = BC = y.

  * A B C equilateral[(x [, b])]
     Defines an equilateral triangle of side length x (default: 6).

Here are all the ways to define a triangle when the first and the second variables are already defined as points:

  * A B C
     triangle(x, y)

     Defines a scalene triangle with BC = x and AC = y.

  * A B C
     triangle(a, a')

     Defines a scalene triangle with measure of the angle under BAC equals a, measure of the angle under CBA equals a'.

  * A B C
     right(x)

     Defines a right triangle (right angle in A) with AC = x.

  * A B C right(a)
     Defines a right triangle (right angle in B) with measure of the angle under BAC equals a.

  * A B C
     isosceles(a)

     Defines an isosceles triangle with measure of the angle under BAC and angle under CBA equal a.

  * A B C isosceles(x)
     Defines an isosceles triangle with AC = BC = x.

  * A B C equilateral
     Defines an equilateral triangle.

Polygons
========

A quadrilateral assignment is a list of 4 variable names followed by the word parallelogram, rectangle or square and some optional parameters. If the first variable is already defined as a point, the quadrilateral is constructed from this point.  If not, the point is set to origin. The optional parameter b is the polar angle of segment AB (default: 0 degrees). Here are all the ways to define a quadrilateral when the second variable is not already defined as a point:

  * A B C D
     parallelogram[(x, y, a [, b])]

     Defines a parallelogram with AB = x, AD = y and angle under BAD equals a (default: 5, 4 and 75 degrees).

  * A B C D
     parallelogram(u, v [, b])

     Defines a parallelogram with vector from A to B equals u and vector from A to D equals v.

  * A B C D
     rectangle[(x, y [, b])]

     Defines a rectangle with AB = x and AD = y (default: 6 and 6 / `golden ratio').

  * A B C D
     square[(x [, b])]

     Defines a square with AB = x (default: 4).

Here are all the ways to define a quadrilateral when the first and the second variables are already defined as points:

  * A B C D
     parallelogram(x, a)

     Defines a parallelogram with AD = x and angle under BAD equals a.

  * A B C D
     rectangle(x)

     Defines a rectangle with AD = x.

  * A B C D
     square

     Defines a square.

When the three first variables are already defined as points, one may also use:

  * A B C D
     parallelogram

  * A B C D
     rectangle

A pentagon assignment is the following command:

  * A B C D E
     pentagon(F, x, a)

     It defines a pentagon of center F, radius x and such as polar angle of segment FA equals a.

An hexagon assignment is the following command:

  * A B C D E F
     hexagon(G, x, a)

     It defines an hexagon of center G, side length x and such as polar angle of segment GA equals a.

Interactive assignments
=======================

An interactive assignment is the following command:

  * x [ = ] interactive(y, z, [ x', x'',] str, f)

With eukleides, variable x is simply set to y.

With xeukleides, it allows, while viewing, to modify the value of the numerical variable x using the arrow keys. The initial value of x is y, the increment is z. The optional parameters x' and x'' are the lower and upper bounds of x. The string str has to contain one uppercase letter. To modify x, one has to press first the corresponding key (at the beginning, the default state is A). The permitted values of f are right (in this case, x will be incremented by pressing the right arrow key and decremented by pressing the left arrow key) or up (in this case, x will be incremented by pressing the up arrow key and decremented by pressing the down arrow key).

When the equal symbol is not present, one may capture the actual value of variable x. In this case, parameter y has to be a simple number (not an expression). When pressing the F1 key, the initial value in the source code is replaced by the actual value and the program switches to editing mode.

Setting commands
================

Here are all the setting commands:

  * box(x, y, x', y' [, z])

  * frame(x, y, x', y' [, z])
     With eukleides, sets the visible frame (the two commands have similar effects). The lower-left corner has coordinates (x, y) and the upper-right corner (x', y'), the optional parameter sets the unit length to z cm (default: 1).

     With xeukleides, the figure is drawn using the largest scale such that the given frame fits into the drawing area. Command box sets the visible frame, therefore the figure is usually surrounded by two gray stripes. Command frame sets the least visible frame, hence the entire drawing area is used. Parameter z has no effect.

     If no frame is given it is set to default frame: (-2, -2, 8, 6).

  * color(f)
     Sets color to f. Permitted values of f are black (default), darkgray, gray, lightgray, white, red, green, blue, cyan, magenta and yellow.

  * color str
     With eukleides, sets color to str (it has to be a valid PSTricks color). With xeukleides, it has no effect.

  * thickness(x)
     With eukleides, multiplies the current linewidth by x. The default linewidth is 0.5 pt. With xeukleides, it has no effect.

  * style(f)
     Sets the current drawing style to f. Permitted values of f are full, dashed and dotted. The default drawing style is full.

  * tricks str
     With eukleides, adds an initial `\' to str and puts it verbatim to the output. It has to be valid TeX code. With xeukleides, it has no effect.

  * font str
     With xeukleides, changes current font. String str has to be a valid XLFD. With eukleides, it has no effect.

  * strokes(x)
     Sets the number of strokes drawn by a trace command (default: 150). The minimal number of strokes is 3 and the maximal number is 300.

Drawing commands
================

Here are all the drawing commands:

  * draw(A [, f [, x]])
     Draws point A with a shape corresponding to f and a scaling ratio x (default: 1). Permitted values of f are dot, disc, box, cross and plus (default: dot). The scaling ratio has no effect with xeukleides.

  * draw(u, A [, f])
     Draws vector u from point A. If f is given, it overrides the current drawing style. Permitted values of f are full, dashed and dotted.

  * draw(l [, f [, f']])
     Draws line l. If f is given, it overrides the current drawing style. Permitted values of f are full, dashed and dotted. Permitted values of f' are entire, halfline and backhalfline (default:  entire).

  * draw(s [, f [, f']])
     Draws segment s. If f is given, it overrides the current drawing style. Permitted values of f are full, dashed and dotted. Permitted values of f' are noarrow, arrow, backarrow and doublearrow (default: noarrow).

  * draw(c [, f])
     Draws circle c. If f is given, it overrides the current drawing style. Permitted values of f are full, dashed and dotted.

  * draw(c, a, a', [, f [, f']])
     Draws an arc of circle c from point of argument a to point of argument a'. If f is given, it overrides the current drawing style. Permitted values of f are full, dashed and dotted. Permitted values of f' are noarrow, arrow, backarrow and doublearrow (default: noarrow).

  * draw(cc [, f])
     Draws conic curve cc. If f is given, it overrides the current drawing style. Permitted values of f are full, dashed and dotted.

  * draw(cc, x, y [, f])
     Draws an arc of conic curve cc. Number x is the argument of the start point (in respect of the internal parametric representation of cc), number y is the argument of the end point. If f is given, it overrides the current drawing style. Permitted values of f are full, dashed and dotted.

  * draw(A, B, C, [, f])
     Draws triangle ABC. If f is given, it overrides the current drawing style. Permitted values of f are full, dashed and dotted.

  * draw(A, B, C, D [, f])
     Draws quadrilateral ABCD. If f is given, it overrides the current drawing style.  Permitted values of f are full, dashed and dotted.

  * draw(A, B, C, D, E,
     [, f])

     Draws pentagon ABCDE. If f is given, it overrides the current drawing style. Permitted values of f are full, dashed and dotted.

  * draw(A, B, C, D, E, F
     [, f])

     Draws hexagon ABCDEF. If f is given, it overrides the current drawing style. Permitted values of f are full, dashed and dotted.

  * draw(str, A, [ x, ] a)
     Prints the text contained in str at a distance x (default: 0.3) and with argument a in respect of point A.

  * draw(str, s, [ x, ] a)
     Prints the text contained in str at a distance x (default: 0.3) and with argument a in respect of the midpoint of segment s.

  * draw(x, [str, ] A, [ y, ] a)
     Prints the value of x optionally formated with str (using the C language syntax) at a distance y (default: 0.3) and with argument a in respect of point A.

  * draw(x, [str, ] s, [ y, ] a)
     Prints the value of x optionally formated with str (using the C language syntax) at a distance y (default: 0.3) and with argument a in respect of the midpoint of segment s.

  * draw(x, x', str, A,
     [ y,] a)

     Prints the values of x and x' formated with str (using the C language syntax) at a distance y (default: 0.3) and with argument a in respect of point A.

  * draw(x, x', str, s,
     [ y,] a)

     Prints the values of x and x' formated with str (using the C language syntax) at a distance y (default: 0.3) and with argument a in respect of the midpoint of segment s.

  * label(A, [ x, ] a)
     Prints the  name of variable A at a distance x (default: 0.3) and with argument a in respect of point A.

  * mark(s [, f [, x]])
     Marks the segment s with a symbol corresponding to f and a scaling ratio x (default: 1). Permitted values of f are simple, double, triple and cross (default: simple).

  * mark(A, B, C [, f [, x]])
     Marks the angle under ABC with a symbol corresponding to f and a scaling ratio x (default: 1). Permitted values of f are simple, double, triple, dashed (which yields a curved angle mark with a dash), right, dot (which yields a curved angle mark with a centered dot), dotted (which yields a right angle mark with a centered dot), arrow and backarrow (default: simple).

Trace commands
==============

A trace command allows to draw the locus of a point depending on a numerical variable. It has the following syntax:

  * trace(x, x', x'' [, f])

This statement has to be followed by at least one point valued expression enclosed in braces (depending on variable x). Parameters x' and x'' are the lower and upper bounds of x. The expression has to be defined for each value of the interval. If not, it may lead to spurious results or sometimes (with eukleides) to an error message. Within the braces, in order to perform intermediate computations, it is possible to add any sequence of statements before the expression. If f is given, it overrides the current drawing style. Permitted values of f are full, dashed and dotted.

PSTricks
========

The program eukleides allows to include arbitrary PSTricks macros with parameters computed itself. Probably most usefully, it allows arbitrary PSTricks graphics objects to be drawn with coordinates generated by a Eukleides construction.

The syntax is meant to be reasonably close to how one would enter PSTricks code directly into a (La)TeX document. A PSTricks macro starts with a backslash, followed by the PSTricks macro name (e.g. pscircle). There may be an optional list of PSTricks options, enclosed in square brackets (i.e. []), and an optional list of parameters, enclosed in parentheses. We first give a simple example illustrating all of these features, and then explain the syntax in detail.

     A B C equilateral
     draw(A, B, C, dotted)
     \pscurve[arrows="->"](A, B, C)

This draws an interpolated spline through the vertices of an equilateral triangle.

The detailed syntax is explained below.

Options
-------

Options should be given in form option=value where option is a legitimate PSTricks option name and value is either a quoted string (e.g. arrows="->") or a Eukleides numerical expression (e.g. radius=distance(A,B)).  Quotes are removed from strings before emitting PSTricks code. All documented option names should work unquoted, but in case of problems, you can enclose the option name in quotes (e.g. "obscureParameter"=3.145).

The following modifies the first example of this section making the lines thicker and drawing the control points of the curve.

     A B C equilateral
     draw(A, B, C, dotted)
     \pscurve[showpoints="true", linewidth=.05, arrows="->"](A, B, C)

Parameters
----------

Parameters to PSTricks macros should be given as a comma separated list of point expressions, numerical expressions, or quoted strings. Points are output in form (x,y) and quoted strings and numerical expressions are output inside braces. This means that the statement:

     \psline("<<->>", A, B)

is translated into the following PSTricks code:

     \psline{<<->>}(0.0000,0.0000)(6.0000,0.0000)

Caveats
-------

This brief documentation cannot hope to explain PSTricks to a novice. For more information, you are referred to the documention included with PSTricks, or to the book ``The LaTeX Graphics Companion'' by M. Goosens, F. Mittelbach and S. Rahtz. To make matters worse, no checking is done to the PSTricks code generated. This means that it is easy to generate syntactically incorrect TeX using this feature of eukleides. Finally, all PSTricks macros are currently ignored by xeukleides.

Export commands
===============

With xeukleides, export commands allow to send numerical values to the standard output. With eukleides, export commands do nothing. The syntax is the following:

  * export(x, [ y, [ z ]])

When exporting more than one value, the numbers are separated with tabs.

Samples
*******

The following samples are intended to illustrate the basic features of Eukleides. There are two other sets of samples: one for eukleides, picked up from geometry exercises; an other for xeukleides, giving examples of interactive geometric figures.

Incircle and bisectors
======================

     A B C triangle
     draw(A, B, C)
     draw(incircle(A, B, C))
     draw(bisector(B, A, C), dotted)
     draw(bisector(A, B, C), dotted)
     draw(bisector(B, C, A), dotted)

Feuerbach circle
================

     A B C triangle
     a = projection(A, line(B, C))
     b = projection(B, line(A, C))
     c = projection(C, line(A, B))
     draw(A, B, C)
     draw(a) ; draw(b) ; draw(c)
     draw(segment(A, a), dotted)
     draw(segment(B, b), dotted)
     draw(segment(C, c), dotted)
     draw(barycenter(A, B))
     draw(barycenter(B, C))
     draw(barycenter(C, A))
     draw(circle(a, b, c))

Isosceles triangle
==================

     A B C isosceles
     H = projection(C, line(A, B))
     draw(A, B, C)
     draw(H)
     draw(segment(C, H), dashed)
     mark(B, H, C, right)
     mark(segment(A, H))
     mark(segment(B, H))
     mark(segment(A, C), cross)
     mark(segment(C, B), cross)
     mark(B, A, C, double)
     mark(C, B, A, double)

Collinear points
================

     A B C D square
     A B E equilateral(4)
     B F G equilateral(4, 30:)
     draw(A, B, C, D)
     draw(A, B, E)
     draw(B, F, G)
     draw(line(E, F), dotted)

Angles in a parallelogram
=========================

     A B C D parallelogram(5, 4, 105:)
     draw(A, B, C, D)
     mark(B, A, D)
     mark(D, C, B)
     mark(C, B, A, double)
     mark(A, D, C, double)

Addition of vectors
===================

     A B C D parallelogram
     draw(segment(A, B), full, arrow)
     draw(segment(A, C), full, arrow)
     draw(segment(A, D), full, arrow)
     draw(segment(B, C), dotted)
     draw(segment(D, C), dotted)

Tangents to a circle
====================

     O = point(2, 2)
     C = circle(O, 2)
     A = point(6.5, 2)
     c = circle(O, A)
     I J intersection(C, c)
     color(lightgray)
     draw(line(A, I))
     draw(line(A, J))
     color(black)
     draw(O, plus)
     draw(A)
     draw(C)
     draw(c, dotted)

A spiral
========

     frame(-5, -4, 5, 4)
     trace(t, 0, 3*360)
     { point(t/360, t:) }

A parabola with focus and directrix
===================================

     F = point(3, 1.5)
     D = line(point(1, 0.5), -65:)
     C = parabola(F, D)
     draw(F)
     draw(D)
     draw(C)

Contact
*******

Eukleides has been created by Christian Obrecht.

Up to now, the canonical homepage for Eukleides is http://www.eukleides.org.

Please send bug reports and comments to obrecht@altern.org.