Difference between revisions of "DynamicCoordinates Command"

From GeoGebra Manual
Jump to: navigation, search
Line 2: Line 2:
 
{{command|geogebra}}
 
{{command|geogebra}}
 
;DynamicCoordinates[ Point A, Number X, Number Y ]
 
;DynamicCoordinates[ Point A, Number X, Number Y ]
:creates a point with coords (X, Y). This point is dependent, but can be moved. Whenever you try to move the new point to coordinates (x,y), point ''A'' is moved there and  coordinates for the new point are calculated. Works best if point ''A'' is not [[Object Properties#Visibility|visible]]. At least one of ''X'' and ''Y'' should depend on ''A''.
+
:Creates a point with coords (X, Y). This point is dependent, but can be moved. Whenever you try to move the new point to coordinates (x,y), point ''A'' is moved there and  coordinates for the new point are calculated. Works best if point ''A'' is not [[Object Properties#Visibility|visible]]. At least one of ''X'' and ''Y'' should depend on ''A''.
  
 
{{Example|1=<div>
 
{{Example|1=<div>
* B=DynamicCoordinates[A,round(x(A)),round(y(A))]. You try to move ''B'' to (1.3,2.1) using the [[Image:Tool Move.gif]] [[Move Tool]]. Point ''A'' becomes (1.3,2.1) and ''B'' appears at (1,2). Create three [[Slider Tool|slider]] a, b, and c with an interval from 0 to 1.
+
* <code>B=DynamicCoordinates[A,round(x(A)),round(y(A))]</code>. When you try to move ''B'' to (1.3,2.1) using the [[Image:Tool Move.gif]] [[Move Tool]], point ''A'' becomes (1.3,2.1) and ''B'' appears at (1,2).  
* B=DynamicCoordinates[A,x(A),min(y(A),sin(x(A)))] create a point under under sin(x).  
+
* <code>B=DynamicCoordinates[A,x(A),min(y(A),sin(x(A)))]</code> creates a point under under sin(x).  
; {{note|PointIn[y<sin(x)] is easier solution in this last  case.}}</div>}}
+
; {{note|PointIn[y<sin(x)] is the easier solution in this case.}}
 +
* The following examples show other ways to restrain the positions of a point C: let A=Point[xAxis] and B=Point[xAxis]. Now type in the Input bar: <code>DynamicCoordinates[B, Min[x(B),x(A)],0] </code>, and press the Enter key,  <code> SetVisibleInView[B, 1, false]</code>, and press the Enter key,  <code>SetLayer[C, 1]</code>, and press the Enter key.  Now, C cannot be moved to the right of A.
 +
*Define A=(1,2). Now, type in the Input bar:  <code>SetVisibleInView[A, 1, false]</code> and press the Enter key,  <code> B=DynamicCoordinates[A, If[x(A) > 3, 3, If[x(A) < -(3), -3, If[x(A)< 0, round(x(A)), x(A)]]], If[x(A) < 0, 0.5, If[y(A) > 2, 2, If[y(A) <0, 0, y(A)]]]]</code>, and press the Enter key.
 +
*This example makes A a sticky point when a point C is dragged near it. Define A=(1,2) and B=(2,3). Now, type in the Input bar: <code>SetVisibleInView[B, 1, false]</code> and press the Enter key, <code>C=DynamicCoordinates[B, If[Distance[A, B] < 1, x(A), x(B)], If[Distance[A, B] < 1, y(A), y(B)]]</code>.</div>}}

Revision as of 18:14, 22 June 2011



DynamicCoordinates[ Point A, Number X, Number Y ]
Creates a point with coords (X, Y). This point is dependent, but can be moved. Whenever you try to move the new point to coordinates (x,y), point A is moved there and coordinates for the new point are calculated. Works best if point A is not visible. At least one of X and Y should depend on A.
Example:
  • B=DynamicCoordinates[A,round(x(A)),round(y(A))]. When you try to move B to (1.3,2.1) using the Tool Move.gif Move Tool, point A becomes (1.3,2.1) and B appears at (1,2).
  • B=DynamicCoordinates[A,x(A),min(y(A),sin(x(A)))] creates a point under under sin(x).
Note: PointIn[y<sin(x)] is the easier solution in this case.
  • The following examples show other ways to restrain the positions of a point C: let A=Point[xAxis] and B=Point[xAxis]. Now type in the Input bar: DynamicCoordinates[B, Min[x(B),x(A)],0] , and press the Enter key, SetVisibleInView[B, 1, false], and press the Enter key, SetLayer[C, 1], and press the Enter key. Now, C cannot be moved to the right of A.
  • Define A=(1,2). Now, type in the Input bar: SetVisibleInView[A, 1, false] and press the Enter key, B=DynamicCoordinates[A, If[x(A) > 3, 3, If[x(A) < -(3), -3, If[x(A)< 0, round(x(A)), x(A)]]], If[x(A) < 0, 0.5, If[y(A) > 2, 2, If[y(A) <0, 0, y(A)]]]], and press the Enter key.
  • This example makes A a sticky point when a point C is dragged near it. Define A=(1,2) and B=(2,3). Now, type in the Input bar: SetVisibleInView[B, 1, false] and press the Enter key, C=DynamicCoordinates[B, If[Distance[A, B] < 1, x(A), x(B)], If[Distance[A, B] < 1, y(A), y(B)]].
© 2024 International GeoGebra Institute