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)).
Author of the construction of GeoGebra: Rafael Losada