# Template page without comments: Moving one point with another

- Author:
- Jonas Hall

## Introduction

These two points are created as independent points, but with scripting we can make them move as one object. We can even make one point move both while the other is independent. Try dragging either point in the construction below!
(This side originally created by Jonas Hall)

## Sample construction

## When to use

This trick with two points may not be useful in itself, but variants of it can be extremely useful, such as these:

- Define a line through two points, A on the y-axis and B anywhere. Make sure that when you move A, then B moves with it so that the slope isn't changed. Moving B will not affect A and so only the slope is changed (This particular example should go on a page of it's own).
- "Grouping" objects so that one point acts as the anchor of the entire group.

## How do you do this?

The construction above uses the following KEY ELEMENTS:

**Two points**: Create two points, A and B.**Scripts for each point**: To make the two points move at the same time when either of them is moved you need to do a little scripting. In the onUpdate script of point A, type: `SetValue[B , ( x(A)+1, y(A)+1 ) ]`

and In the onUpdate script of point B, type:`SetValue[A , ( x(B)+1, y(B)+1 ) ]`

In this case the offset between the points is (1, 1) but this could obviously be generalized by using a variable (DO give more examples). To make A move both points while B is independent, just use the script for point A and leave point B unscripted.

## Screencast of construction

## More examples

One point dragging both, but not the other way round: https://www.geogebra.org/m/UEFW7KBV