Can you have relative points?

Michael Borcherds shared this question 15 years ago
Answered

Hi,


Is it possible to have a point B that stays a fixed distance from point A when point A is moved, but can itself be moved independently?

(ie like a vector)


If I define point B as (x(A) + 3, y(A) + 2) it almost works, however dragging point B also moves point A.


thanks!

Comments (22)

photo
1

Hi murkle


Have a look at the examples here:

http://www.zenbikermaniac.f...

I hope one of them is what you are looking for.


Zen Biker Maniac

photo
1

No, none of them are quite right :(


thanks anyway!

photo
1

Hi murkle


The answer may be in your question - try a vector.

Referring again to: http://www.zenbikermaniac.f...

specifically to the Vector example at the bottom of the page.

Points A4 and O4 can be moved independently of each other.

It is also possible to move u (click and drag anywhere on the vector line).


To create a vector, select mode Vector between two points

then click at two positions (tail and head).


The mode Vector from point makes use of an existing vector and point.

Select the mode, click on the point (tail) then click on the line of the vector.

(The order doesn't matter - Click on vector then point gives the same result.)


If this is still does not do what you want then you are up against the basic mathematics of GeoGebra.

I suspect it can be done in GeoGebra with some added Javascript.

Please feel free to give more detail of what you are wanting to do.


Zen Biker Maniac

photo
1

I was trying to make a circle where dragging the centre point moves the circle without changing the radius, and also with a draggable point on the circumference.

photo
1

Hi murkle


The closest you can get with GeoGebra (without Javascript) is

- New Point :arrow_right: A

- Circle with centre A and radius 3 say :arrow_right: c

- New Point on c :arrow_right: B


Move A moves everything (A, B, c).

Move B moves A on c without moving A or c.

Optionally, c can be hidden without affecting the behaviour of A an d B.


Zen

photo
1

Hi again


The addition of Javascript will give you a solution:

http://www.zenbikermaniac.freesurf.fr/geogebra/pre_release/index.html

Click the button labelled Semi-Free on the right.

The particular Javascript calls used here are quite resource hungry

so be patient while it loads and don't move the points too quickly.

Also in this example the points have been set to snap to grid.


You can also read the discussion that went on during development:

http://www.geogebra.org/for...

including a link to the French forum.


All the Best

Zen Biker Maniac

photo
1

Perfect, thanks!

photo
1

There seems to be a bug somewhere (in the JavaScript?) here:


http://www.zenbikermaniac.f...


To see it, drag the point A to (3,-2) and the point B jumps to (5.000000000000028, -8.881784197001252e-16)


More generally if point B is "p" units above A and you move A so that it has a Y-coordinate of "-p" then B jumps off.


It looks like it might be a "divide by zero" bug but I can't see any division.


[Windows XP, Firefox 2.04/IE6]

photo
1

Hi Murkle


That's interesting. I hadn't noticed that (or chose to ignore it?).

More generally if point B is ...
Even more generally, for any A(x, y) and B(x+p, y+q)

i) one form of the bug shows when A is on the line x = -p

ii) another form shows when A is on the line y = -q

iii) there is a combined form when A is at the intersection point (-p, -q).

These movements of A should respectively place the point B

i) on the y-axis ... (0, any)

ii) on the x-axis ... (any, 0)

iii) at the origin ... (0, 0)

Instead, the point B is not shown and the gradient of the line is wrong.


The B coordinate could be the source of 0 for a divide-by-zero bug.

But, as you observe, there is no division in the Javascript code.

I originally posted this example as a demonstration of how to use the new calls.

My own experience was that the performance was too slow on classroom computers.

So I didn't develop any more in this direction.

I'll think about it some more and post any further thoughts here.


All the Best

Zen Biker Maniac

photo
1

I think I've found a workaround. I stripped the code down first but the problem was still there. However when I changed the logic slightly it disappeared. I've introduced offX and offY.


Does it now work for you?


:)


    <script type="text/javascript">


    var xA;

    var yA;

    var xB;

    var yB;

    var offX;

    var offY;


    function startup() {


    document.Animated.registerObjectUpdateListener("A", "updateListenerA");

    xA = document.Animated.getXcoord("A");

    yA = document.Animated.getYcoord("A");


    document.Animated.registerObjectUpdateListener("B", "updateListenerB");

    xB = document.Animated.getXcoord("B");

    yB = document.Animated.getYcoord("B");

    offX=document.Animated.getXcoord("B")-document.Animated.getXcoord("A");

    offY=document.Animated.getYcoord("B")-document.Animated.getYcoord("A");


    } //end startup


    function updateListenerA(objName) {

    var tmp;

    xA = document.Animated.getXcoord("A");

    yA = document.Animated.getYcoord("A");


    xB = xA + offX;

    yB = yA + offY;

    // Unregister and Register to avoid a cascade of calls

    document.Animated.unregisterObjectUpdateListener("B");

    document.Animated.evalCommand("B= ("+xB+", "+yB+")");

    document.Animated.registerObjectUpdateListener("B", "updateListenerB");


    } //end updateListenerA


    function updateListenerB(objName) {

    offX=document.Animated.getXcoord("B")-document.Animated.getXcoord("A");

    offY=document.Animated.getYcoord("B")-document.Animated.getYcoord("A");

    } //end updateListenerB


    </script>

photo
1

Hi murkle


I've tried your code and there is no sign of any bug.

Unfortunately, the essential functionality is lost. :?

That is, Point A can be moved without moving Point B.

I was a bit short of time to check it any further.


I also tried turning off the 'Snap to Grid' but no effect on bug.


Zen

photo
1


Unfortunately, the essential functionality is lost. :?

That is, Point A can be moved without moving Point B.


Definitely works here :)

photo
1

you wrote the answer

(ie like a vector)

thanks!


the order is very important

A=(0,0) by click in origin

B free

C free

D=A+C

hide C

E=D+B-A


you can move D and E keep distance but you can move E freely


saludos

photo
1

That's very neat, thanks. I knew it was possible somehow :)


I think you've made a small mistake, this works for me:


A=(0,0) by clicking on the origin

B free

C free

D=A+C

hide D

E=D+B-A


you can move C and E keeps the same distance but you can move E freely


Now to make a Tool...

photo
1

Hi murkle, mathmagic


:exclamation: Something fundamental has changed between GeoGebra 2.7 and 3.0

:question: I think a bug may have been introduced.

:arrow_right: http://www.geogebra.org/for...

:bulb: If I am correct, it is this new bug which provides the functionality in this example.

:cry: Unfortunately, I think this example will not work when the bug is removed.

:D ... or I could be wrong.


Zen

photo
1

if you like GG 2.7 you can do this:


A,B,C free points

D=A+B/2+C/2-A


then A move freely and D move A


hidding B,C break the object of construction so redefine B=(-20000,?) C=(20000,?) and get them out of the window


saludos

photo
1

Unfortunately, I think this example will not work when the bug is removed.


Sadly I think you're right. Looks like Markus fixed that bug at some point :(

photo
1

That's very neat, thanks. I knew it was possible somehow :)


I think you've made a small mistake, this works for me:


A=(0,0) by clicking on the origin

B free

C free

D=A+C

hide D

E=D+B-A


you can move C and E keeps the same distance but you can move E freely


Now to make a Tool...


You can eliminate A from the above since its coordinates are zero.


E.g., if A equals zero, then B - A = B.

photo
1

I invented the previous method, but now C is the one who moves to E


best


    A free

    B free

    segment[A,B]

    C=B+0*A

    hide B


it seems that C move A and really A is moved by segment


saludos

photo
1

Brilliant!!! (again).


thanks.

photo
1

i have seen you have used the trick in protractor page with the obvious addition (to use white colour and thin style)


in some case (moving the segment over a polygon) you can see a ghost white line over poly

here is another method without this problem

A free

B free

C free

CircularArc[A,B,C]

move B over A

hide A

hide B

D=B+(0,0)


to move D will move C but C is free


indeed: have you try the trick with conic through five point? four free and one guiding

it can be useful for desing traslations of fickle triangles


saludos

photo
1

here is another method without this problem

A free

B free

C free

CircularArc[A,B,C]

move B over A

hide A

hide B

D=B+(0,0)


to move D will move C but C is free


This doesn't seem to work when you save and reload.


indeed: have you try the trick with conic through five point? four free and one guiding

it can be useful for desing traslations of fickle triangles



I don't understand - have you got an example?


thanks!

© 2023 International GeoGebra Institute