.: Script :.

The steps of any geometric construction could be encapsulated as an algorithm. This will be here referred as an script. For instance, the following steps produce the perpendicular bisector of any given 2 points:

// given any 2 point, labeled by A and B
1: c0:= Circumference ( A,B )
2: c1:= Circumference ( B,A )
3: C:= PointIntersection_north ( c0,c1 )
4: D:= PointIntersection_south ( c0,c1 )
5: r:= Line ( A,B )
Algorithm: perpendicular bisector of two given points

The script presented above use a synthetic language, in a form of command instructions of a computer language. For instance, the command c0:= Circumference ( A,B ), indicates that will be created a new geometric object, labeled as c0. This object is a circumference whose center is the point A and whose radius is defined by the distance between A and the point B (therefore, B is one point of c0).

This synthetic language could be obtained from any iGeom construction. In the applicative version, this is done using the menu File | Save algorithm..., while in the applet version of iGeom, this could be done clicking on the middle button of the mouse, when it is over the drawing area (is your mouse hasn't the middle button, try to press simultaneously both buttons - in some systems this combination emulates the middle button).

It must be observed that the above description is nothing else than an algorithm. This algorithm must be applied to 2 points and generate their "perpendicular bisector line". For this reason, it could be refered as a geometric algorithm.

It is also worthwhile that, to apply the above algorithm, it is required a pair of points (A e B) in order to get their perpendicular bisector. These pre-existents objects are called parameters of this script. Therefore, after to register this script in iGeom, every time was necessary to get the perpendicular bisector of a pair of points, the user must select these points and then to apply the script on them (see the section bellow).

In the perpendicular bisector script, the order of the parameters (the 2 points) is irrelevant, but it is not always the case. For instance, in the Algebraic context, the division algorithm for two numbers produces different results if the parameters order are changed (a/b or b/a).

How to construct an script in iGeom

There are 4 basic phases related to an script, which is explained below in a cronological order: launch the recorder; register all the constructions steps; register/save/send the script; and how to use an script. The first three phases are done once and the last one is repeated every time that the script is required. Each one of these phases are explained below, using the perpendicular bisector example. At the beginning of the phase explanation, when is the case, is presented the associated iGeom button, located at the left of the first line.

1. Launching the recorder
Before to launch the recorder, it is necessary to have into the drawing are, all the initial objects (those that will define the parameters). After this, the user must "click" on the Script annotation button (here presented at the beginning of this paragraph).
Just before the user "click" on the referred button, if the "mouse" is passed over it, the message that will appear into the messages bar, of both iGeom versions (the applicative one as well as the applet version), is: Begin Script generation.
It notices that, in both versions of iGeom, after the user "click" on the Script annotation button, it will be opened the window of steps annotation/saving of an script. This window is presented at left side of the figure 1 and has 2 main areas:
  1. Area for the parameters: it is the superior portion of the window, in which the iGeom insert as a parameter, all the objects used during the script generation that was not created after the window opening.
    A parameter object is an object that will be used by the script in order to accomplish the construction
  2. Area for the algorithm steps: it is the central portion of the window, in which the iGeom will present all the registered steps of the script.
    It is used just to inform the user about each step registration, using the already quoted "legible" language. This is the same language used into the example perpendicular bisector algorithm.
The figure 1 presents the situation of the drawing area just after the script recorder be launched, considering the perpendicular bisector constructor. The final situation of this script annotation process is presented into the figure 2, in which can be observed the 5 steps necessary to the construction, using the synthetic language.

Figure 1: at the left is the steps annotation window for script, yet empty.

Example: construct the points A and B; active the script buttons "clicking" on the primary button above presented; launch the script annotation/saving window, "clicking" on the secondary button with the icon already quoted. This example is shown at the figure 1, at its left side is the window for steps annotation of the script (still empty) and at its right side is the drawing area of the iGeom with the correspondent construction.

2. Registering all the constructions steps
With the annotation window open, the user must do all the necessary steps to obtain the construction. Each of these steps will be annotated into the script, which is shown in the figure 2, at its left side. During this phase, it will be annotated both portions of the script, beyond the steps notation, also the parameters will be registered.
Parameters: The script parameter perform the same role as the parameter of a mathematical function (for instance, the pair of parameter x,y for the real function f(x,y) = x/y).
The iGeom automatically "deduces" these parameters, that are: all the object (that is used to construct any other object) among those that were present at drawing area previously to the script annotation process begin, will be a parameter.
In order to indicate that some object is a parameter for the script under construction, the object label will appears on the superior portion of the annotation window (the window leftmost in figure 1). Actually, it is similar to any math function, what really matters is the objet "type", not the registered object label. This label is just to inform the order of its parameter (remember the example of the division algorithm). The parameter order is very important when the script has some recurrence.
Steps: An script step is an elementary instruction applied on a set of objects that are "associated to it" (an example of this, is the instruction to construct the circumference defined by the points A and B in the perpendicular bisector algorithm).
The set of objects on which the script can use, are those objects that were construct by it or its parameters. These are the quoted "associated to it (script)" objects.
An elementary instruction could be the construction of a new object (as a circumference) or the alteration/edition of any object (as the color change of a circumference trace).
The iGeom allows an special kind of step, that is a recurrent reference. In order to make a proper use of this feature, it is necessary to pay much attention to the parameters order, as explained just below this paragraph.
By simplicity, an object construct by an script instruction, will be referred to as "constructed by the script".
Recurrence: Is an script instruction representing a recursive/recurrent application of itself.
The behavior of a recursive (or recurrent) script is identical to a recursive function. A very known example of recursive function is the factorial function, here represented by fat:
fat: IN -> IN
fat(n) := { 1, if n=0; n * fat(n-1), if n>0 }.
A recursive function is characterized by a reference to itself (the use of its name in its "right side of the definition"), as the reference fat(n-1) in the factorial example. The same characterization is applied to a recursive script.
It is strongly recommended that all the recurrence instructions appear at the end of the script, as its last steps.
In order to register a recursive reference in an script, the user must:
  1. Select/mark (with the selector ) any list of objects that are compatible to the parameters requested by the script under construction. Usually this action demands attention, since you must respect the objects type and their order as shown in the script parameters. This is one reason to keep all the recurrence instructions as the last anes of the script, so all the parameters are already defined. If new parameter appears (by the use of a pre-existent object) after the user put a recurrence instruction, the iGeom will launch a message error. This error is similar to the the following incorrect definition of a recursive function: f(x,y):={1, if x=y; 1+f(x), if x<>y}   (note that the function has 2 parameters - f(x,y), however in the recursive instruction was used only one parameter - 1+f(x)).
  2. "Click" on the button to register the recursion .
    If the recursion was correctly used (this is, the selected objects matches the requested parameters to the script under construction), then, after the "click" iGeom will register this instruction with a line similar to Recurrent (parameter_list).
    In order to get a better understanding of recursive script and to realize their benefits, please see the section Tetra-circle.


Figure 2: at the left side there is the annotation window (at the top appears the parameters and in its central portion the scripts steps).

Example: in order to construct the perpendicular bissector script, the user must construct 2 points, then must launch the annotation window and then must construct any necessary steps. For instance, the user could does the the following steps: circumference c0 with center A and radius defined by B; circumference c1 with center B and radius defined by A; to define the C point, resultant of the "north" intersection between the circumference c0 and c1; to define the D point, resultant of the "south" intersection between the circumference c0 and c1; to define the line r, correspondent to the perpendicular bissector (of points A ad B in figure 1).
This example appears at the left side of the window in figure 2, there are 5 steps indicated in central portion of the annotation window of script. At the right side of figure 2, there is the correspondenting construction in the drawing are of iGeom.

2. Registering (saving/sending) the script
After the annotation windows is launched, if the user pass the "mouse" over the button save/annotate, the message will be different from that before the window be launched. The message will be: Annotate script.
Once the construction is finished, the user must annotate the script, what is quite different in applicative and in the applet version. The annotation is made with a "click" on the same button that opened the annotation window (in figure 2).
  1. Applicative: Using applicative version of iGeom, the "click" results in a dialog window to choose a name (and location) to save the script.
  2. Applet: Using applet version of iGeom, the "click" results in the automatic annotation of the script in one of the "Script buttons defined by the user". There are 4 of these buttons, the iGeom will register the script in the first one that is empty. If all of them is used, the iGeom will register the script in the last one (in this case, the script previously in this position will be "erased").
The Script buttons defined by the user is accessed with a "click" in the primary button , resulting in the secondary row with these buttons: , , and . When the user moves the "mouse" over one of these buttons, if it contains a script it will appears in the message bar a list of objects (parameters) that is required to use this script.
Example: in the perpendicular bissector script, the parameters are Point and Point. In this script the order of the parameters is selected not important.

4. How to use an script (applying the algorithm)
or If there is an available script, the user could applies it how many times it is necessary. To do this, the user must at first to use the selector to mark the objects that will be used as basis to the script. If some incompatibility is detected, the iGeom presents at the message bar some instruction about the mistake.
In the applet version it only possible to use an script that is available under one of the Script buttons defined by the user (from to ). The initial action is to mark the parameters script, then the user must "click" in one of the script defined by user.
In the applecative version of iGeom, besides the possibility to work with script defined by user, it also possible to get an script saved on the file system. In this case, the user must select the required parameters and then "click" on the secondary button apply Script. In the opened window, the user must choose the script and "click" the OK button.
Another applicative exclusive feature is the association of script to one of the script defined by user, using the scripts button option in the menu bar (as showed in figure 3). After the user "click" the option add script..., it will appear the window in figure 4. In this window the user could select the script button (1 to 4) that will receive the script (in the figure 4, is the script button number 2). The figure 4 indicates that the script saved in the file with name perp_bissect-en.scr will be associated to the script button number 2 and the message that will be shown to the user whener the "mouse" move over this button is point, point: script to construct the perpendicular bissetor.
An important recomentation here is to write, as a description of the script, what are the parameters and the purpose of the script, as indicated in figure 4. Without this information the user couldn't realize what it does and what to use as parameters.
After the user "click" the OK button, the information linking scripts file with scripts button is saved on the file with name scripts.txt in the same directory where is iGeom.

Figure 3: option Add script... is used to link an script to one of the scripts button, under applicative iGeom.


Figure 4: window to select and comment the script linked with the scripts button number 2.