Differenze tra le versioni di "Tutorial:Il comando Tartaruga"

Da GeoGebra Manual.
Riga 32: Riga 32:
 
==Costruire un quadrato==
 
==Costruire un quadrato==
  
Validate successively each of the following commands in Input :
+
Per fare costruire a una ''tartaruga'' di nome ''t'' un quadrato di lato 1 a partire dall'origine del sistema di coordinate, digitare nell'ordine i seguenti comandi, premendo il tasto {{KeyCode|Invio}} al termine di ogni inserimento:
  
<code>t=Turtle[]</code><br/>
+
<code>t=Tartaruga[]</code><br/>
<code>TurtleForward[t,1]</code><br/>
+
<code>TartarugaAvanti[t,1]</code><br/>
<code>TurtleLeft[t,90°]</code><br/>
+
<code>TartarugaSinistra[t,90°]</code><br/>
<code>TurtleForward[t,1]</code><br/>
+
<code>TartarugaAvanti[t,1]</code><br/>
<code>TurtleLeft[t,90°]</code><br/>
+
<code>TartarugaSinistra[t,90°]</code><br/>
<code>TurtleForward[t,1]</code><br/>
+
<code>TartarugaAvanti[t,1]</code><br/>
<code>TurtleLeft[t,90°]</code><br/>
+
<code>TartarugaSinistra[t,90°]</code><br/>
<code>TurtleForward[t,1]</code><br/>
+
<code>TartarugaAvanti[t,1]</code><br/>
 
 
Of course, as announced from the start, nothing happens in Graphics, after the appearance of the turtle and the Play button, just if Algebra is open, you may notice changes in the coordinates of the point ''t''.
 
(reminder: do not deprive yourself of the functionality "Replay" for Input field !!!)
 
and finally press the [[Image:Animate Play.png]]  Play button
 
  
A turtle, named ''t'', will build a direct square, side 1, from the origin.
+
Dopo l'inserimento dei comandi solo in ''vista Algebra'' è visibile la posizione finale della tartaruga ''t'', mentre il movimento della tartaruga non sarà visualizzato nella ''vista Grafici'' finché non si preme il pulsante [[Image:Animate Play.png]] ''Esegui''.
  
Obviously, the input of these 8 command lines is tedious, especially when you know that it can be reduced to an input of 2 lines :
+
Obviously, the input of these 8 comando lines is tedious, especially when you know that it can be reduced to an input of 2 lines :
  
 
<code>t=Turtle[]</code><br/>
 
<code>t=Turtle[]</code><br/>
Riga 57: Riga 53:
 
Immediately, a remark, the passage of global arguments work, so if a numeric variable ''c'' is defined  :<br/>
 
Immediately, a remark, the passage of global arguments work, so if a numeric variable ''c'' is defined  :<br/>
 
<code>Repeat[4, TurtleForward[t, c], TurtleLeft[t, 90° ]]</code><br/>
 
<code>Repeat[4, TurtleForward[t, c], TurtleLeft[t, 90° ]]</code><br/>
The turtle ''t'', will build a direct square, side ''c'', from the origin, backwards, if ''c'' is negative.
+
The tartaruga ''t'', will build a direct square, side ''c'', from the origin, backwards, if ''c'' is negative.
But the trace will not be affected by a subsequent change in the value of ''c''.
+
But the trace will not be affected by a subsequent change in the valore of ''c''.
  
  
And without further ado, validate successively each of the following commands in Input :
+
And without further ado, validate successively each of the following comandi in Input :
  
 
<code>c=1</code><br/>
 
<code>c=1</code><br/>
Riga 69: Riga 65:
 
The execution trace you these classic square 5 nested respective sides 1, 2, 3, 4 and 5.
 
The execution trace you these classic square 5 nested respective sides 1, 2, 3, 4 and 5.
  
<center> [[Image:CarrésEmboîtés.png]]</center>
+
<cInvio> [[Image:CarrésEmboîtés.png]]</cInvio>
  
  
Riga 79: Riga 75:
 
I will use the GeoGebra Scripts attached to objects to define procedures. I chose deliberately as object type "text", which allows me to easily display the listing,
 
I will use the GeoGebra Scripts attached to objects to define procedures. I chose deliberately as object type "text", which allows me to easily display the listing,
  
I select Text tool, and validate :
+
I select Text strumento, and validate :
  
 
<code>For Square :c</code><br/>
 
<code>For Square :c</code><br/>
Riga 88: Riga 84:
 
in Scripting / On Click tab (don't forget to press the "Ok" button)
 
in Scripting / On Click tab (don't forget to press the "Ok" button)
  
The execution of the following 2 commands :<br/>
+
The execution of the following 2 comandi :<br/>
 
<code>c=2</code><br/>
 
<code>c=2</code><br/>
 
<code>t=Turtle[]</code><br/>
 
<code>t=Turtle[]</code><br/>
Riga 99: Riga 95:
 
<code>For NestedSquares :n :c</code><br/>
 
<code>For NestedSquares :n :c</code><br/>
  
<code>Repeat[n,RunClickScript[Square],SetValue[c,c+1]]</code><br/>
+
<code>Repeat[n,RunClickScript[Square],Setvalore[c,c+1]]</code><br/>
  
 
after validating <br/><code>c=1</code> and <br/><code>n=5</code>, <br/>one <b><u>click</u></b> on this new text gives me the construction of previous nested squares.
 
after validating <br/><code>c=1</code> and <br/><code>n=5</code>, <br/>one <b><u>click</u></b> on this new text gives me the construction of previous nested squares.
Riga 118: Riga 114:
 
<code>TurtleRight[t,135°]</code><br/>
 
<code>TurtleRight[t,135°]</code><br/>
  
<center> [[Image:Feuille.png]]</center>
+
<cInvio> [[Image:Feuille.png]]</cInvio>
 
      
 
      
 
<code>Pour Epi</code><br/>
 
<code>Pour Epi</code><br/>
Riga 127: Riga 123:
 
<code>TurtleRight[t,90°]</code><br/>
 
<code>TurtleRight[t,90°]</code><br/>
 
   
 
   
<center> [[Image:Épi.png]]</center>
+
<cInvio> [[Image:Épi.png]]</cInvio>
  
 
<code>Pour Champ</code><br/>
 
<code>Pour Champ</code><br/>
 
<code>Repeat[3,RunClickScript[Epi],TurtleUp[t],TurtleForward[t,4],TurtleDown[t]]</code><br/>
 
<code>Repeat[3,RunClickScript[Epi],TurtleUp[t],TurtleForward[t,4],TurtleDown[t]]</code><br/>
  
<center> [[Image:Champ.png]]</center><br/><br/>
+
<cInvio> [[Image:Champ.png]]</cInvio><br/><br/>
  
 
With a management button whose script :<br/>
 
With a management button whose script :<br/>

Versione delle 18:10, 12 giu 2015


Digitando il comando Tartaruga[] nella barra di inserimento viene creato nella vista Grafici un punto chiamato tartaruga1 Tortue.png di coordinate (0, 0) e orientato in direzione del semiasse positivo delle ascisse .

Contemporaneamente, nell'angolo in basso a sinistra della vista Grafici è visualizzato anche il pulsante Animate Play.png Esegui (che diventa Animate Pause.png Pausa quando si fa clic su di esso).

Una tartaruga non è altro che un punto animato, che inizia a muoversi non appena viene premuto il pulsante Animate Play.png Esegui oppure viene applicato il comando AvviaAnimazione[]. Tutti i comandi impartiti alla tartaruga mentre è visualizzato il pulsante Animate Play.png Play vengono memorizzati da GeoGebra e saranno eseguiti nell'ordine dopo la pressione del pulsante.

La finestra di dialogo Proprietà dell'oggetto tartaruga è la stessa dell'oggetto punto, anche se con funzionalità limitate o leggermente differenti: ad esempio la modifica del colore non viene applicata alla tartaruga, ma solo ad una sua eventuale traccia.

Per modificare la posizione della tartaruga è possibile utilizzare il comando ImpCoordinate[Oggetto, x, y], mentre per determinare la posizione della tartaruga nel piano è possibile utilizzare le funzioni x() e y(), anche se è necessario tenere presente che tali funzioni restituiscono la posizione finale della tartaruga, indipendentemente dal fatto che i comandi di movimento siano stati eseguiti o meno.

Comandi specifici per la tartaruga

  • Traslazione
TartarugaAvanti e TartarugaIndietro:
la tartaruga si muove avanti o indietro in linea retta della distanza indicata.
  • Rotazione
TartarugaDestra e TartarugaSinistra:
la tartaruga ruota su se stessa a destra o sinistra dell'angolo indicato.
  • Traccia:
TartarugaGiù:
la tartaruga indicata lascia una traccia del proprio movimento.
TartarugaSu,
la tartaruga indicata non lascia una traccia del proprio movimento.

Sono inoltre applicabili alla tartaruga molti altri comandi, tra i quali Esegui[], Ripeti[] e i comandi EseguiScriptAgg[] ed EseguiScriptClic[].

Costruire un quadrato

Per fare costruire a una tartaruga di nome t un quadrato di lato 1 a partire dall'origine del sistema di coordinate, digitare nell'ordine i seguenti comandi, premendo il tasto Invio al termine di ogni inserimento:

t=Tartaruga[]
TartarugaAvanti[t,1]
TartarugaSinistra[t,90°]
TartarugaAvanti[t,1]
TartarugaSinistra[t,90°]
TartarugaAvanti[t,1]
TartarugaSinistra[t,90°]
TartarugaAvanti[t,1]

Dopo l'inserimento dei comandi solo in vista Algebra è visibile la posizione finale della tartaruga t, mentre il movimento della tartaruga non sarà visualizzato nella vista Grafici finché non si preme il pulsante Animate Play.png Esegui.

Obviously, the input of these 8 comando lines is tedious, especially when you know that it can be reduced to an input of 2 lines :

t=Turtle[]
Repeat[4, TurtleForward[t, 1], TurtleLeft[t, 90° ]]


Immediately, a remark, the passage of global arguments work, so if a numeric variable c is defined :
Repeat[4, TurtleForward[t, c], TurtleLeft[t, 90° ]]
The tartaruga t, will build a direct square, side c, from the origin, backwards, if c is negative. But the trace will not be affected by a subsequent change in the valore of c.


And without further ado, validate successively each of the following comandi in Input :

c=1
n=5
Repeat[n,Repeat[4, TurtleForward[t, c], TurtleLeft[t, 90° ]],SoitValeur[c,c+1]]

The execution trace you these classic square 5 nested respective sides 1, 2, 3, 4 and 5.

<cInvio> CarrésEmboîtés.png</cInvio>


"Process"

The Logo's philosophy was rather define "procedures", realizing a basic working, procedures are then solicited a group to make a more complex task.

I will use the GeoGebra Scripts attached to objects to define procedures. I chose deliberately as object type "text", which allows me to easily display the listing,

I select Text strumento, and validate :

For Square :c

Repeat[4, TurtleForward[t, c], TurtleLeft[t, 90° ]]

By opening the properties of this text, I renames Square, and I do a copy / paste of instruction in Scripting / On Click tab (don't forget to press the "Ok" button)

The execution of the following 2 comandi :
c=2
t=Turtle[]
and one click on the text

built as expected a square of side 2

So now with other text in the same file, I renamed NestedSquares :

For NestedSquares :n :c

Repeat[n,RunClickScript[Square],Setvalore[c,c+1]]

after validating
c=1 and
n=5,
one click on this new text gives me the construction of previous nested squares.


Example page 55 de "Logo, des ailes pour l'esprit" ("Alas para la mente" Horacio C. Reggini)

[File on GeoGebra]


Pour Feuille
TurtleLeft[t,45°]
TurtleForward[t,2]
TurtleBack[t,2]
TurtleLeft[t,90°]
TurtleForward[t,2]
TurtleBack[t,2]
TurtleRight[t,135°]

<cInvio> Feuille.png</cInvio>

Pour Epi
TurtleLeft[t,90°]
TurtleForward[t,5]
Repeat[3,TurtleRight[t,90°], RunClickScript[Feuille], TurtleLeft[t,90°], TurtleForward[t,1.25]]
TurtleBack[t,8.75]
TurtleRight[t,90°]

<cInvio> Épi.png</cInvio>

Pour Champ
Repeat[3,RunClickScript[Epi],TurtleUp[t],TurtleForward[t,4],TurtleDown[t]]

<cInvio> File:Champ.png</cInvio>

With a management button whose script :
Delete[t]
t=Turtle[]
SetCoords[t,-8,-1]
StartAnimation[]

© 2024 International GeoGebra Institute