• Overview
  • Quick Start
  • Samples
  • Download
  • Legacy
  • Quick Start

    Drawing a triangle

    Although being a computer language, Eukleides is rather close to the natural language of geometry. For instance, to draw a scalene triangle, just type the following in your favorite text editor:

    A B C triangle
    draw (A.B.C)
    

    and save it as, say, triangle.euk. Then, within your favorite terminal emulator, type:

    $> eukleides triangle.euk
    

    This creates a file named triangle.eps containing the following figure:

    A scalene triangle

    The first line of this script is a multiple assignment. Such assignments allow to define the vertices of the most common kind of polygons in a single statement. Quite often in elementary geometry the actual length of the sides are not relevant. Using the triangle command without parameters yields an optimal scalene triangle.

    The second line is a drawing statement. The dot operator groups points A, B, and C in a set. The enclosing parentheses are mandatory in order to make the drawing command consider this set as a closed path.

    Another triangle

    Eukleides provides ways to define various kinds of geometric objects. For instance, let ABC be a right triangle in B such as AB = 5 cm, and ∠ BAC = 35°. The following script draws ABC and its circumcircle.

    A B C right 5, 35°
    draw
      (A.B.C)
      circle(A, B, C)
    end
    

    It yields the following figure:

    A right triangle

    Command parameters (as in line 1), contrary to function parameters (as in line 5), are not enclosed in parentheses. When not available the degree symbol may be replaced by deg. Lines 2 to 5 consist in a drawing block, which allows to draw several objects without repeating the draw keyword.

    Marking and labelling

    Enhancing the figure above with point names and a right angle mark requires the following lines.

    label
      A -135°
      B -45°
      C  45°
      A, B, C right
    end
    

    We obtain:

    A right triangle with labels

    Lines 2 to 4 show a convenient way to label points provided they are stored in variables. The additional parameter sets the position of the label with respect to the point. As in line 5, objects in labeling (or drawing) blocks may have optional parameters.