Using scripts

This activity belongs to the GeoGebra book Linkages. In this activity there are three bars of length 1 unit. However, the construction process is different in each case: 1) AB bar. In this case, while A is free (for example, A=(1,3)), B is a dependent point of A, since it is located on the circle with center A and radius 1. Moving A drags the bar. By moving B, this point rotates around A. The bar cannot be moved directly. Naturally, we can also choose to construct point A as a dependent point of B. In such a case, moving B would drag the bar, while moving A would rotate this point around B. This is the usual way of building objects in Dynamic Geometry: the order of construction is essential to determine the behavior of objects, since this order influences the way in which some depend on others. We cannot, using this usual way, create two points A and B with the same type of interdependence, that is, that they behave the same when moved. 2) CD bar. Both points are free. Move C rotates this point around D. Move D rotates this point around C. The bar can be dragged independently. Now, how to ensure that, being free, points C and D maintain the distance of 1 unit between them? The answer lies in the use of scripts (instruction or sequence of instructions). Moving point C triggers the following script: SetValue(C, Intersect(Ray(D,C), Circle(D,1))) This instruction forces C to maintain that distance from D.
  • Note 1: Note that we have not used C = Intersect(Ray(D,C), Circle(D,1))) as this statement would redefine C as a dependent point of D. Instead, C retains its definition as a free point but we force it to reposition itself and take the value resulting from intersecting Ray(D,C) with Circle(D,1).
  • Note 2: Scripts can achieve the same result in various ways. For example, an equivalent script to the above could be the statement SetValue(C, D + UnitVector(C-D)).
Similarly, moving point D triggers the following script: SetValue(D, Intersect(Ray(C,D), Circle(C,1))) 3) EF bar. Both points are free. The bar can be dragged independently. When moving E, this point drags F in its movement, thanks to the following script: SetValue(F, Intersect(Ray(E,F), Circle(E,1))) Likewise, when moving F, this point drags A in its movement: SetValue(E, Intersect(Ray(F,E), Circle(F,1))) Let us observe that the behavior of the EF bar is the one that is closest to the real behavior of a physical bar of length 1 unit. However, the three representations maintain the same algebraic limitation (distance between the ends of the bar equal to 1) and, at first glance, they are identical... as long as we do not interact with them. It is in this interaction where the use of scripts allows escaping from the corset imposed by the typical construction process of Dynamic Geometry.
Author of the construction of GeoGebra: Rafael Losada