2. Constrain Movement by Scripting

The horizontal red segment is defined by the hidden [u]free points[/u] G and H. To constrain it to move vertically between D and E, the following GeoGebra scripts are applied on [b]Scripting | On Update [/b]tab of the following points.[br][br][u]Point G[/u][br][b]SetValue(G, If(y(G)y(E), E, (x(E), y(G)))))[/b][br][u]Point H[br][/u][b]SetValue(H, If(y(H)y(E), (x(C), y(E)), (x(C), y(H)))))[br][/b][br]Similarly, to constrain the movement of the vertical red segment defined by the hidden [u]free points[/u] I and J, the following scripts are applied.[br][br][u]Point I[/u][br][b]SetValue(I, If(x(I)x(C), (x(C), y(E)), (x(I), y(E)))))[br][/b][u]Point J[/u][br][b]SetValue(J, If(x(J)x(C), C, (x(J), y(D)))))[/b]

Information: 2. Constrain Movement by Scripting