# Difference between revisions of "Point 'fixed' in one direction"

From JSXGraph Wiki

Jump to navigationJump to searchA WASSERMANN (talk | contribs) |
|||

(2 intermediate revisions by 2 users not shown) | |||

Line 1: | Line 1: | ||

− | + | ''A'' and ''B'' are free points. Whenever the board is updated, e.g. | |

− | after a drag event, the x-coordinate of | + | after a drag event, the x-coordinate of ''A'' is set to 1 and |

− | the y-coordinate of | + | the y-coordinate of ''B'' is set to 1. Therefore, ''A'' moves |

− | on | + | on the vertical line through x=1, ''B'' moves on the horizontal line through y=1. |

<jsxgraph width="600" height="600"> | <jsxgraph width="600" height="600"> | ||

var brd = JXG.JSXGraph.initBoard('jxgbox',{axis:true,boundingbox:[-1,2,2,-1]}); | var brd = JXG.JSXGraph.initBoard('jxgbox',{axis:true,boundingbox:[-1,2,2,-1]}); | ||

Line 9: | Line 9: | ||

var B = brd.create('point', [0,1]); | var B = brd.create('point', [0,1]); | ||

− | brd.on(' | + | brd.on('move', function(){ |

A.moveTo([1, A.Y()]); | A.moveTo([1, A.Y()]); | ||

B.moveTo([B.X(), 1]); | B.moveTo([B.X(), 1]); | ||

}); | }); | ||

− | |||

</jsxgraph> | </jsxgraph> | ||

Line 23: | Line 22: | ||

var B = brd.create('point', [0,1]); | var B = brd.create('point', [0,1]); | ||

− | brd.on(' | + | brd.on('move', function(){ |

A.moveTo([1, A.Y()]); | A.moveTo([1, A.Y()]); | ||

B.moveTo([B.X(), 1]); | B.moveTo([B.X(), 1]); |

## Latest revision as of 11:09, 21 February 2013

*A* and *B* are free points. Whenever the board is updated, e.g.
after a drag event, the x-coordinate of *A* is set to 1 and
the y-coordinate of *B* is set to 1. Therefore, *A* moves
on the vertical line through x=1, *B* moves on the horizontal line through y=1.

### The JavaScript code

```
var brd = JXG.JSXGraph.initBoard('jxgbox',{axis:true,boundingbox:[-1,2,2,-1]});
var A = brd.create('point', [1,0]);
var B = brd.create('point', [0,1]);
brd.on('move', function(){
A.moveTo([1, A.Y()]);
B.moveTo([B.X(), 1]);
});
```