Home

“Turtleworlds” Manual - Educational Technology Lab

image

Contents

1. eeeeeeeeee esee esee eene e nennen nennen nnns nnns nnns 9 3 1 PrimitiVes uon et ener e Rete ERR Ite ed pr erret a e 9 3 2 Procedures Sub procedures oo eecccccesssesssnsccecesssenssseceecesssessaeessecsseseesaseseeseseeessaeeecceseeesaaeesseeeseenas 9 3 37 jProced re construction ona a cde um c ee tr EET DE EUER PEE Feo aaro 10 3 3 1 Procedure inputs rto nire am en OC RR YU ERR E aes Erhard 11 3 4 Sub procedures Hyperprocedures sssssccccccseesssscssccccsessssasseesessesnssseceecesseenssseeeccesseenssasesseeseeenas 12 4 Dynamic manipulation Variation tools e eee e creen eee ee eene eene nnn nnne nnn nnns nsns n anneau 13 41 IheVariation LOO sce ci t Er d ERES NER NEVER ES EFE RR RELAIS EFE RA NOS A d FTe a SEAT Pe sae 13 4 2 he2D Variation TOOl sesenta dede enti te egest oer ev 3e ke e nk eva eda seu ue Eres eeu etae 14 43 Arn ex mbple ecd cett cae eee ded ce x ee eae Da vede ae ue Ee EE NO Reed Ye NV 16 5 Re Petition StructUre uem 18 6 RECUISIVE PrOCCCUI OS s K 20 7 Control commands 3 rere e iere d ee eese aier ikeir ewe ense sinu deu geo u ae evan use vae Ck nbus deoa ag 21 7 1 Control commands in recursion iieeesss sese eene ha nasse sena aas a sss esas arias assa sesso aaa 21 Appendix A Tables of Commands eee e ee eee esee eee eee eene eene e hh sensns sans e sess e sess sss e ease sees s s
2. LU uy uu um UU ERE us orn Example 2 Diagonal formation of a canonical polygon with recursion In the following example the use of recursion is demonstrated for the construction of all the diagonals of a n gon The defined procedures are the following to diagonals n s repeat n design diagonals n s 2 It n 3 180 n fd s rt 360 n end to design diagonals n s k if k gt n 2 stop rt 180 n fd length diagonal n s k bk length diagonal n s k design diagonals n s k 1 end to diameter n s E EDUCATI ONAL TECHNOLOGY LAB ETL 28 Turtleworlds MANUAL output 2 s sin 180 n 2 2 n sin 360 n end to length diagonal n s k output diameter n s sin 180 k n end The main procedure is the diagonals n s which takes as inputs the number of n sides of the polygon and the s length of the side Then for each angle of the polygon the procedure design diagonals is called which recursively designs the angle s diagonals In the following figure an example of an 8 gon with a length side of 60 is displayed The execution is realized with the diagonals 8 60 command Example 3 Designing the Rosette shape by applying recursion The rosette design is a complex one constructed on the basis of geometric rules and functions First a number of concentric circles are designed with a radius of twice three times and so on the radius of the inner circle Next the inner
3. helps in the syntax of a legible and structured code Attention t is mandatory to close every open bracket The commands called upon in the brackets could be any Turtleworlds commands procedures defined by the user Moreover the number of repetitions could be a variable For example the following procedure could be defined E EDUCATI ONAL TECHNOLOGY LAB ETL 18 Turtleworlds MANUAL to parallelograms times a b angle Repeat times parallelogram a b angle right 30 End The parallelograms procedure repetitively calls the parallelogram procedure set above as many times as the variable value times defines Thus for example the execution Parallelograms 4 30 50 60 Has the following outcome on the Canvas P d EDUCATI ONAL TECHNOLOGY LAB ETL 19 Turtleworlds MANUAL 6 Recursive procedures In the Hyperprocedures and sub procedures section the way one procedure is called within another was described Turtleworlds also allows for a procedure to call itself This is called recursion Suppose you have defined the following procedure concerning the formation of a circle with radius r to circle r repeat 36 forward 2 pi r 36 right 10 end Suppose you have also defined the procedure for butterfly r repeat 2 circle r rt 180 end which formulates two externally tangent circles as shown in the following figure An example of the use of recursion in this procedure is the following to bu
4. of numbers words or other data An input command consists of such data that are indispensable for its execution An output command is the outcome after its execution A command may require none one or many inputs whereas it can have none or one output In particular the commands in Turtleworlds are composed as follows CommandName space inputl space input2 etc Some basic Turtleworlds commands regarding turtle control will be presented next together with the way they are composed and executed 2 2 Movement of the turtle on the surface In order to move the turtle on Canvas a number of movement commands can be used which define the way and the degree of its movement For the turtle to move forward by a specific number of steps the command forward should be used The command forward has an input which should be a number and defines the steps the turtle will proceed This number is written straight after the command The result of the command is for the turtle to move towards the direction of its head in a distance of as many steps as the value of the number in the command input As the turtle moves it leaves the relevant trace behind For example the command Forward space 50 asks the turtle to move 50 steps forward For any command written in the Editor to be executed either the button ins INSERT or the button gt located on the command editor toolbar should be clicked while the editor writing indicator cursor is on the line of
5. the turtle 100 steps forward towards the direction of its head The program perceives that the command forward has as an input the result of the addition 50 50 The same happens with more complex calculations such as Forward 50 20 3 2 The parentheses rules in mathematics apply in complex calculations Turtleworlds perceives the calculations as separate commands as well In other words instead of using numerical symbols there are commands that execute the calculation Eg 30 20 is also perceived as sum 30 20 30 10 is also perceived as difference 3010 30 x10 is also perceived as product 30 10 30 10 is also perceived as quotient 30 10 The above mode to firstly denote the name of the result and then the numbers which are involved in the calculation is very useful when you wish to define calculations as the following Eg 27 as power 2 3 J5 as root 5 For example you may execute the command Forward root 20 For more mathematical commands see Table 2 in Appendix A Note Calculation commands cannot be executed on their own in the Editor For example if the root 36 is run there will appear the message You don t say what to do with 6 This means that the command root was run with the result of 6 but the program does not recognize what to do with this number This happens because the calculation commands have one output the result of the calculation that must apply somewhere Generally the commands that have an output cannot be u
6. therefore the execution continues formulating two tangent circles with a radius of 50 Next it calls upon itself with the n value reduced by 1 and the r value reduced by 10 In this case n 4 and r 40 The execution continues in the same way until it calls upon itself for n 0 Then the control command will be true and the procedure will cease after it has been run for 5 times as many as the n initial value The following table shows in detail the r and r values during all the recursion running stages Control Recursion command Execution flow Value n Value r condition values inel butterfly n 1 r 10 1 5 50 FALSE butterfly 4 40 om 4 40 FALSE butterfly 3 30 3 3 30 FALSE butterfly 2 20 am 2 20 FALSE butterfly 1 10 5th 1 10 FALSE butterfly 0 0 6 0 0 TRUE E EDUCATI ONAL TECHNOLOGY LAB ETL 22 Turtleworlds MANUAL Appendix A Tables of Commands Table 1 Turtle control commands ee i d Cleargraphics or Cg facies But Pues Clears the canvas and restores the turtle to its initial position o Description example Clean Clears the canvas and lets the turtle in its position Forward number or fd number Back number or bk number Right number or rt number Left number or It number Setpencolor value 1 value2 value3 Setxy X position1 position2 SETHEADING degrees Restores the turtle to its initial position without deleting what it has c
7. Educational Technology Lab National and Kapodistrian University of Athens School of Philosophy Faculty of Philosophy Pedagogy and Philosophy P P P Department of Pedagogy Director Prof C Kynigos oes OE ee NEED Microworld Component Tools Help DSHS XR uA e m Br E 2D Variation Tool D amp 9X repr Turtleworlds Manual Ver 5 5 TABLE OF CONTENTS 1 TUTE Teu e RP 4 DD WhatisTurtleworlds niri erre to rede ere eode eee eee paene devel ee ee een ae YES 4 1 2 Description of Turtleworlds AAA E E E E E T E 4 1 2 1 The turtle and the Canvas sess e e iaaea eE aE rE eet 4 1 2 2 TheEditor orc ne ore teri Pet re inrer ee Free e Ye eve Teck e ea pue e Ted orae ve Te code 4 1 2 3 THe Variation tools 5 e cie ete eser ete deese e eee Pede desees edere ed Pese eaae edis 5 2 Basic control turtle guidance ee esee e Leere essen eene eene nennen nens senses sana esses esses sss sees esee seen 6 2 1 Whatisd command Jos c oe ee co pde ee eed e c e eve ure v e Y lia bint 6 2 2 Movement of the turtle on the surface sessi sees ee ennnn nnne eene tn anna nasse arta asas sensa aaa 6 2 3 Calculations using T rtleworlds rre tn meer oie eere ouavibsiuereneesseetteate 7 ZA The turtle S traces cs ite e ER eit ede i tte ei Te aie m e veo sa baa due uie oath es 8 3 Structural language features in Turtleworlds
8. a Turtleworlds primitive command which stops the execution of any procedure run at the same time Thus if the height has a value less than 5 the procedure will immediately stop and the commands concerning the formation of the stair will not be executed So for example if it is executed as stair 4 10 the turtle will not do anything since the condition is true But if it is executed as stair 6 10 The turtle will create a stair An inequality or equation of any two elements can be applied as a condition Condition examples height 5 height gt width height 3 lt 20 7 1 Control commands in recursion The control commands are very useful in the recursive procedures For example in the butterfly procedure of the previous section E EDUCATI ONAL TECHNOLOGY LAB ETL 21 Turtleworlds MANUAL to butterfly n r if n lt 1 stop repeat 2 circle r rt 180 butterfly n 1 r 10 end If there wasn t for the if command the butterfly procedure would call upon itself to infinity By applying control commands you define when the execution of a recursive procedure discontinues Thus if you run the butterfly procedure as butterfly 5 50 what Turtleworlds does is the following Initially it runs the butterfly procedure with the values n 5 and r 50 The if control condition checks whether n is less than 1 When it gets less than 1 the execution of the procedure will cease For the time being this does not apply and
9. ape also changes dynamically This occurs when you drag the cursor over the variation slider With the 2D Variation tool you may see what happens in the shape as you co vary two variables on imaginary vertical axes by freely dragging the cursor on the interface of the component More information about the variation tools in Section 4 The four components can be seen in the following figure Figure 1 Turtleworlds 65 8 S a Microworld Component Tools Help l j Canvas DE Eb X Ha e i de T ED x B7 length_diagonal defined I don t know how to setpencolour 2D Variation Tool D amp X rev E Variation Tool cea Procedure Vai om To Step Figure1 Turtleworlds interface P d EDUCATI ONAL TECHNOLOGY LAB ETL 5 Turtleworlds MANUAL 2 Basic control turtle guidance This section describes through symbolic instructions that are created in the editor area the way to control and guide the turtle 2 1 What is a command As mentioned before the turtle is controlled with the application of the commands written in the Editor The command is the symbolic expression of an instruction which leads to a specific result when executed Each command has a unique name and is composed in a predefined way A command may be simple i e it can be composed only by using its name and execute a specific action or it may include input and output parameters These parameters consist
10. circle is divided into equal arcs The cycle chords of these arcs constitute the isosceles triangles bases whose vertexes are in the next circle The vertex points of the first line triangles constitute the base points of the second line triangles You continue this way until you complete the last line of triangles The functions defined in Turtleworlds are the following fto rhombus a b make 8 arccos b 2 a It 8 repeat 2 fd a rt 2 0 fd a rt 180 2 9 rt 8 end to rosette n a b E EDUCATI ONAL TECHNOLOGY LAB ETL 29 Turtleworlds MANUAL make 8 arccos b 2 a if 8 lt 90 n stop repeat n rhombus a b pu fd b pd It 360 n rt 0 fd a It 2 0 rt 6 180 n rosette n a 2 a cos 0 180 n end The basic procedure is rosette n a b and its execution as rosette 14 31 27 has the following outcome Notice The present Manual has been composed by researchers in the Educational Technology Lab in cooperation with teachers that have extensively used Turtleworlds in the classroom P d EDUCATI ONAL TECHNOLOGY LAB ETL 30
11. command The result of executing the specific command is for the turtle to move 50 steps forward towards the direction of its head The back command which asks the turtle to move a number of steps towards the opposite direction from the direction of its head operates in exactly the same way Example Back space 50 For the turtle s rotation there are the Right and Left commands These commands take as input a number which defines the degrees according to which you wish to turn the turtle s head For example the command Right 90 asks the turtle to turn its head 90 degrees to the right In the same way the command Left 30 asks the turtle to turn its head 30 degrees to the left E EDUCATI ONAL TECHNOLOGY LAB ETL 6 Turtleworlds MANUAL Important tips 1 Tip Pay attention when composing a command Between the name of the command and its input there should be a blank space For example if the command Forward 50 is written without a blank in between Forward50 the message on the editor will be Il don t know what to do with Forward50 because it does not recognize any command with such a name 2 4 Tip Each command may be executed several times as long as the cursor is placed on the line where the command is written and the button ins or the button gt is clicked For example you may execute the command Forward 10 then the command Back 30 and then again the command Forward 10 3 Tip Apart from the individual ex
12. d by its state in other words by a its position and b its orientation Its position is placed in the centre of the circular object and its orientation is defined by the position of its head The turtle has a specific trace colour which is the colour of its head black by default as well as specific size which is adjusted by the settings of its component You may change all these settings when you get familiar with the construction of models 1 2 2 The Editor In the area of the Editor command component you may a write whatever you want i e text numbers arithmetic calculations in the same way we use a blog or word processor and b commands and programs that enable the turtle to change its state This is realized with the use of a programming language called Logo that derives from the ancient Greek word Logismos Calculus and contains a series of commands and constitutes an easy way to define your own commands as many as you wish The commands control and guide the turtle and define the changing values of its state attributes position and orientation Each time a command is executed the turtle responds by creating the relevant shape or event on the Canvas The Editor command area is divided in two parts e the area where the instructions to be executed by the turtle are written in a symbolic way upper part and e the area where responding messages are automatically written by Turtleworlds in accordance to t
13. dure Number Type of input Outcome event of inputs data Cleargraphics 0 Clears the Canvas and restores the turtle in its initial position Right a 1 number Turns the turtle s head a degrees right Left a 1 number Turns the turtle s head a degrees left Penup 0 Raises the turtle s pen Pendown 0 Lowers the turtle s pen 1 Tip The commands also have abbreviations Turtleworlds can understand the commands even with their names written abbreviated Eg the command Cleargrpahics as cg the command right 30 as rt 30 the command left 30 as It 30 e t c 2 Tip Executing the command ask Turtle primitives displays on the lower part of the Editor all these primitives of Turtleworlds both in English and Greek Also in the Appendix of this manual there is a table with the important procedures as well as examples of their use 3 2 Procedures Sub procedures An important feature of Turtleworlds is that it enables the user to create his own commands which are called procedures and sub procedures in the IT language A procedure is a primitive command or a command to which you have given a name of your own choice and you have defined it so that it runs a number of commands In other words Turtleworlds allows you to create your own additional words commands besides the existing primitives and use them wherever and however you wish Every time you define a procedure command it has the same status with the primitive comma
14. ecution of commands as mentioned above there is the possibility of executing numerous commands simultaneously The mode of executing commands is per line In particular there are two modes of simultaneous execution of commands 1 mode Serial execution on different lines from top to bottom Let s say you want to execute the following two lines of command together forward 50 forward 30 First you select them forward 50 forward 30 and then you click on the key ins or the button gt for Turtleworlds to run them in the same order from top to bottom 2 mode Serial execution in one line from left to right Another way to run the above two commands is to write them on the same line as follows Forward 50 forward 30 They are then executed in the same way as one command on the line was executed Placing the cursor on the line and pressing the key ins or the button gt Turtleworlds will execute all the commands in the line from left to right Pay attention to the spaces between the commands and their value inputs 4 Tip The commands may take as an input integer decimal positive and negative numbers Note The command forward 20 has the same outcome as the command back 20 2 3 Calculations using Turtleworlds The commands in Turtleworlds allow to perform calculations within the commands For example the command FY EDUCATI ONAL TECHNOLOGY LAB ETL 7 Turtleworlds MANUAL Forward 504 50 moves
15. h of the stairs If you run the procedure as staircase 30 20 the turtle draws the following shape If you move the mouse into the Canvas you will observe a cross appearing By using this cross you can left click on any part of the turtle s trace Clicking on the trace indicated in the above example the Variation tool below the Canvas acquires two sliders Figure 2 In particular these sliders correspond to the two variables of the stair height width procedure and initially have the values according to which the procedure was run namely height 30 and width 20 These sliders allow you to dynamically change the variable values by moving the respective indexes and automatically observe the changes that take place on the turtle s trace E EDUCATI ONAL TECHNOLOGY LAB ETL 13 Turtleworlds MANUAL Dy AS Gale gt rom H fs S E Monospaced s BI stair height width 4 Aw m staircase redefined lt rJ staircase 23 33 Th e 2 idle ready for commands data input 2D Variation Tool variation D amp X Bs i LBS tools 5 Variation Tool Procedure staircase Figure 1 The variation tools corresponding to the height and width variables From the left and right of the variation height toolbar there are two fields From and To which contain the numbers 15 and 60 respectively These nu
16. he realized actions lower part These messages refer either to an error in the structure of commands or to the correct definition of a new procedure and function as a feedback and troubleshooting guide for the user By using the Editor component you may execute commands as follows place the cursor on the line where the commands you want to execute are located Press the key insert usually found in the keyboard with the initials ins When you press the usual key enter the cursor simply changes line without executing any commands Each time you press the key insert Logo executes the words of the line on which the cursor is placed from left to right When a command is not recognized either due to the fact that it has not been defined or because it E EDUCATI ONAL TECHNOLOGY LAB ETL 4 Turtleworlds MANUAL does not belong to the basic commands there is a message projected saying I don t know how to 1 2 3 The Variation tools With the Variation tool and the 2D Variation tool components you may provoke dynamic constant change to the shapes created by the turtle when it has been given a parametric command that you have defined yourself For stable commands without input variation and for basic commands even with an input the variation tools cannot be activated The Variation tool component changes in a constant way the value s of input variables that you have set for a command At the same time the sh
17. mbers constitute the limits within which the height variable values change You can change these limits and write in the respective fields the numbers of limits that you wish There is one more field called Step which contains number 1 This entails that the variation tool can take values which differ by one unit between the limits you have defined You may change this as well by applying the number you wish The concept of the variation tool can be applied to the formulation of open ended problems such as e Move the indicator that corresponds to the height variation tool and observe the way the staircase inclination changes e Move the indicator that corresponds to the width variation tool and observe the way the staircase inclination changes e Try to figure out the relation between the height and width variables in order for the staircase to maintain its inclination 4 2 The 2D Variation Tool The 2D Variation Tool allows you to represent two of the variables of a specific procedure on an orthonormal system of co ordinates Suppose you have defined the staircase procedure that was described above to staircase height width stair height width stair height width stair height width Zk EDUCATI ONAL TECHNOLOGY LAB ETL 14 Turtleworlds MANUAL End You have already activated the Variation tool On the left side of each slider there is a red right angle By clicking on either side of the angle you ca
18. n set this variable on the corresponding axis of the rectangular axis system represented by the 2D Variation Tool Suppose for example you want to create an axis system where the vertical axis will be the height and the horizontal axis will be the stair width To do this the following procedure must be followed Allocation of the width variable to the horizontal axis On the 2D Variation Tool an orthonormal system with perceptible axes has now been created where the vertical axis corresponds to the height variable and the horizontal one to the width variable of the stair procedure By pressing the key of the 2D Variation Tool you can create checkpoints on the axis system With the key pressed and by clicking on any point of the variation tool surface a blue point is created with specific coordinates The D d EDUCATI ONAL TECHNOLOGY LAB ETL 15 Turtleworlds MANUAL height and width variable values have automatically taken the coordinate values of this point Figure 3 Moving the blue point on the imaginary axis system both values of the height and width variation tools change automatically The blue point coordinates are 35 30 E 2D Variation Tool D amp X Se Et Variation Tool Procedure Figure 4 A point on the 2D Variation Tool in Turtleworlds The button of the 2D Variation Tool projects a grid on the axis system whereas the button clears the variation tool from all the
19. nds Thus you can define a command by using another command you have already defined In this way you create a limitless structure of procedures and sub procedures E EDUCATI ONAL TECHNOLOGY LAB ETL 9 Turtleworlds MANUAL 3 3 Procedure construction Let s say you have edited the following commands Forward 30 Right 90 Forward 50 Left 90 If you run these commands in this order the following shape is created on the Canvas L You can define a procedure that will run the above commands every time in the same order that it will be called For this to be realized you give the command to and a name of your choice for the procedure In a separate line after the end of the series of commands that the new procedure will require it is necessary to enter the word command end Don t forget it In other words the code will be to stair Forward 30 Left 90 Forward 50 Left 90 End The word to is a primitive Turtleworlds command which is used for the definition of a new procedure On the right of the word to the word you have chosen to call the new procedure is written in this particular case stair On the last line the word end is written which informs the system that the procedure initiated with the word to has ended To complete the definition of the new procedure you must select all the lines and press the key ins or the button Then on the lower part of the Editor there will appear the message stai
20. o numbers set in its input i e it performs a p Product a b 2 1 Gives the product of the Product 2 4 two numbers set in its input i e it performs a Quotient a b 2 1 Gives the quotient of 2 the two numbers set in its input i e it performs a b ye EDUCATI ONAL TECHNOLOGY LAB ETL 24 Turtleworlds MANUAL Gives the remainder of Remainder 1 division of the two 112 numbers set in its input Gives the square root of Root 36 the number set in its input It raises the x number Power 2 4 16 to the n power and returns the result Thus it is x It returns the modulus Abs 10 of the number set in its input It returns the cosine of Cos 60 the angle set as an input It returns the sine of Sin 60 the angle set as an input It returns the tangent Tan 180 of the angle set as an input 1 It returns the angle it Arccos 0 5 calculates from the inverse cosine based on the argument set as an input Abs number argument Arcsin argument It returns the angle it Arcsin 0 5 30 calculates from the inverse sine based on the argument set as an input It returns the angle it arctan 1 45 calculates from _ the inverse tangent based on the argument set as an input It returns the exponential function with a base of e and as a power the number set in its input arctan argument Integer number 7 It returns the integer Integer 2 8 2 part of the number set as an inpu
21. or certain conditions to be met P d EDUCATI ONAL TECHNOLOGY LAB ETL 17 Turtleworlds MANUAL 5 Repetition structure Turtlewords allows for the use of a repetitive structure in the editor s code This structure is a primitive which is used for the better flow and organization of the code commands Suppose you want to define a procedure which results to the formation of a variable shaped parallelogram One way to do this is the following to parallelogram a b angle Forward a Right angle Forward b Right 180 angle Repeated code Forward a Right angle Forward b Right 180 angle End This code defines the parallelogram procedure whose commands formulate a parallelogram With the use of the repetition structure the code to be repeated can be written only once Therefore the above code becomes to parallelogram a b angle Repeat 2 Forward a Right angle Forward b Right 180 angle End The word repeat is a Turtleworlds primitive repetition command The number that follows it denotes the times the command is repeated in the specific case 2 The commands inside the brackets are the ones the turtle will repeat as many times as defined by the number Generally the repetition structure is defined as Repeat repetition times Commands to be repeated The repetition structure is very useful since with its application lengthy codes with repetitive commands are avoided Therefore it
22. points that have been created Free draggin If the button is not pressed dragging the mouse on the surface of the 2D Variation Tool with the left key of the mouse continuously pressed you can design lines which correspond to the changes occurring on the shape created by the turtle 4 3 An example Suppose you want to study the fact that the maintenance of the staircase inclination demands that the ratios of the height and width sizes remain stable The 2D Variation Tool helps on the study of the two sizes graphical relation and the inferences concerning the inclination and graphs of similar amounts Suppose the ratio equals 3 in other words height width 3 Try to place the blue point on the 2D Variation Tool in a position where the height width ratio values equals three If you place some more blue points in different positions where the ratio of the two variables equals three the following point set up will occur E120 Variation Tool D 8x m m LIB a EDUCATI ONAL TECHNOLOGY LAB ETL 16 Turtleworlds MANUAL Notice that the points make a straight line with a stable inclination This line also constitutes the height width 3 graph function The rationale of the 2D Variation Tool can be applied to the formulation of open ended problems such as e Move the mouse freely on the surface of the 2D Variation Tool and try to understand from the created trace the way the variables correlate in order f
23. r defined which means that the procedure stair has been defined From now on you can use the word stair as a command For example if you write on the Editor stair and run the command the 4 commands will automatically be executed and the above shape will be created on the Canvas Now that the procedure stair has been defined you can run the procedure as many times as you wish For example if you run 3 consecutive times the procedure the following shape will occur E EDUCATI ONAL TECHNOLOGY LAB ETL 10 Turtleworlds MANUAL Advice The procedures can be named according to your wish as long as 1 It is only one word The name stair up is not acceptable because it consists of two words separated with a space The name stair up is acceptable 2 t is not a name that corresponds to a primitive Turtleworlds command For example the name forward is not acceptable For your own convenience it would be better for the names of the commands to be relevant with what the procedure denotes 3 3 1 Procedure inputs The procedures can have inputs and outputs the same way as Turtleworlds commands This is executed with the use of variables By using a variable the above procedure can be realized to stair height Forward height Forward 90 Forward 50 Left 90 End The height of the stair is now variable and can be defined by the user during the execution of the procedure For example if you run the command as stai
24. r 40 a stair is created with a height of 40 steps Attention Every time you use a variable in the code the symbol must precede its name After do not leave a space The names of the variables must also be a consecutive word Another example of the use of variables is the following to stair height width Forward height Right 90 Forward width Left 90 End In this example both the height and the width of the stair are variable and defined by values that are given as inputs at the execution of the command This procedure can be run as stair 40 80 so that a stair is created with 40 height and 80 width It is important that you write E EDUCATI ONAL TECHNOLOGY LAB ETL 11 Turtleworlds MANUAL the variable values in the order they were defined in the procedure in the specific example first write the value of the height and then the value of the width Advice A procedure may have as input as many variables as you wish 3 4 Sub procedures Hyperprocedures Turtleworlds allows for other procedures to be called within the procedures Suppose the aforementioned procedure stair height width has been defined You may define a new procedure which will execute the following to stair height width stair 30 40 stair height width End The new procedure stair calls the procedure stair twice as a standard command The first time it is called with stable values whereas the second time with values that the procedure s
25. reated Moves the turtle forward as many steps as the number value Moves the turtle backward as many steps as the number value Turns the turtle right by as many degrees as the number value Turns the turtle left by as many degrees as the number value The turtle ceases to write on the Canvas Places the turtle on the canvas coordinates position1 position2 Orientates the turtle by as many degrees as the degrees input value Forward 10 or fd 10 Back 10 or bl 10 Right 90 or rt 90 Left 90 or It 90 Setpencolor 255 0 Red colour for more colours see below Setxy 30 40 SETHEADING 90 Za EDUCATI ONAL TECHNOLOGY LAB ETL 23 Turtleworlds MANUAL Recalls the turtle s position coordinates Recalls the turtle s abscissa position sna th ui NENNEN ordinate position canvaspagewidth EE NEN NEN the Canvas width e canvaspageheight EEEN Recalls the Canvas height LL Basic colour codes RBG for the turtle s change of colour Red 255 0 0 Green 0 255 0 Blue 0 0 255 Black 255 255 255 Yellow 255 255 0 Orange 255 128 0 To see all the colours visit the site http www rapidtables com web color RGB_Color htm and choose the relevant codes Table 2 Mathematical function commands in Turtleworlds Command of of Description Inputs Outputs 2 1 Gives the sum of the Sum 35 two numbers set in its input i e it performs acp Difference a b 2 1 Gives the difference of M 8 the tw
26. sed individually but only as input to other commands 2 4 The turtle s trace As mentioned above when the turtle moves on the Canvas it leaves a trace This trace can be controlled by a number of commands For example you can define whether the turtle leaves a trace as it moves or not This is realized with the commands pendown and penup respectively The command penup turns the turtle s head white which means that if the turtle moves it will leave no trace whereas in the case of the command pendown the turtle s head will turn black and the turtle will leave a trace behind Furthermore there is the command cleargraphics cg which deletes anything the turtle has designed so far on the Canvas and restores the turtle to its initial position with its head turned upwards as it was initially Finally there are several commands regarding the change of colour and density of the turtle s trace included in table 1 of Appendix A E EDUCATI ONAL TECHNOLOGY LAB ETL 8 Turtleworlds MANUAL 3 Structural language features in Turtleworlds 3 1 Primitives Turtleworlds includes a number of commands and functions as the ones described above forward cleargraphics right etc These commands are called primitives and possess the following features e They run either a command or a function e They may take value inputs or not e They may have an output value or not Some basic typical primitives are presented below Proce
27. so nnus 23 Table 1 Turtle Control commands iacu cea tiec tere ease aea covvennnodoesasbe sane 23 Table 2 Mathematical function commands in Turtleworlds essei eese eene 24 Appendix B Additional examples for the use of Turtleworlds ee ecce eere eene 27 Example 1 Waves with StqirCOSe S cccccssssscccccsssessssscecccssesssaeeesecceseessuseesecceseessuaeceecesseessaaeesesesseeaaaess 27 Example 2 Diagonal formation of a canonical polygon with recursion eeeesseeeee nennen 28 Example 3 Designing the Rosette shape by applying recursion cesses 29 Turtleworlds MANUAL 1 Turtleworlds 1 1 What is Turtleworlds Turtleworlds is a tool of symbolic expression in mathematical activity by means of programming for the creation and tinkering of dynamic graphical models 1 2 Description of Turtleworlds Turtleworlds consists of four distinct and yet connected work areas These areas are called components Each component is defined to run specific activities or functions 1 2 1 The turtle and the Canvas On the left side of Turtleworlds appears the component Canvas which also includes the turtle The canvas is a surface on which the turtle leaves its trace as it moves unless you prefer it does not leave a trace The turtle apart from being a cute pet in Turtleworlds constitutes a strictly defined mathematical entity It is define
28. t Za EDUCATI ONAL TECHNOLOGY LAB ETL 25 Turtleworlds MANUAL Rounding number FY EDUCATI ONAL TECHNOLOGY LAB ETL 26 Turtleworlds MANUAL Appendix B Turtleworlds Additional examples Example 1 Waves with staircases Write and define the following procedure to stair upper forward 2 right 90 forward 5 left 90 end Write and define the following procedure to stair lower right 90 forward 5 right 90 forward 2 left 180 end Write and define the following procedure to staircase upper repeat 5 stair upper end Write and define the following procedure to staircase lower repeat 5 stair lower end Write and define the following procedure to staircase upright staircase upper staircase lower end Write and define the following procedure to staircase reverse staircase lower staircase upper the use of E EDUCATI ONAL TECHNOLOGY LAB ETL 27 Turtleworlds MANUAL end Write and define the following procedure to waves Repeat 11 staircase upright staircase reverse end When the last procedure waves is run it calls the staircase upright sub procedure as well as the staircase reverse sub procedure which in turn call the staircase upper sub procedure and the staircase lower sub procedure with the latter to call next the stair upper and stair lower sub procedures respectively As a consequence the turtle creates on the Canvas area something that looks like waves as seen below
29. tair itself takes as an input In this particular case the procedure stair is called sub procedure and the staircase hyperprocedure Another example is the following to doubleStairs height width stair height width stair height 2 width 2 End The procedure creates initially a stair with the height and width that you have defined as parameters and then one more stair with double height and width The outcome from the execution of the above procedure as doubleStairs 20 30 is the following Advice In a hyperprocedure such as the stair you can call many different procedures For example if you had also defined a procedure stair up you could have called apart from this one the procedure stair as well within the procedure staircase E EDUCATI ONAL TECHNOLOGY LAB ETL 12 Turtleworlds MANUAL 4 Dynamic manipulation Variation tools In this section the other two components of Turtleworlds are described the Variation Tool and the 2D Variation Tool 4 1 The Variation Tool The Variation Tool allows you to dynamically manipulate the variables of a function you have defined For example you have defined the following procedure to staircase height width stair height width stair height width stair height width End The procedure staircase calls 3 times the sub procedure stair and creates three consecutive stairs It has two variables height and width which define the height and widt
30. tterfly n r if n 1 stop repeat 2 circle r rt 180 Recursion The procedure calls upon itself butterfly n 1 r 10 end What is accomplished with the butterfly procedure above is the formation of two tangent circles and calling upon itself by applying a radius reduced by 10 r 10 This is done for n times Therefore if you run the procedure as butterfly 5 50 the turtle creates the following shape E EDUCATI ONAL TECHNOLOGY LAB ETL 20 Turtleworlds MANUAL 7 Control commands In the butterfly example in the previous section the following command was found within the code of the procedure if n 1 stop This is a Turtleworlds control command These commands allow you to check the code execution flow of a procedure based on certain conditions that you define In the specific case we deal with the if command The if command checks the condition that follows right after in the specific n 1 If the condition applies the procedure runs the commands written in the brackets Suppose the following procedure has been defined to stair height width If height 5 stop Forward height Right 90 Forward width Left 90 End The command If checks at this point if the condition height 5 is true If it is true then it will run the stop command otherwise if it is false it will ignore the brackets and continue normally with the execution of the following commands The stop command is

Download Pdf Manuals

image

Related Search

Related Contents

10-288型 取扱説明書 保証書付 ガステーブルコンロ  Poulan 410241 Tiller User Manual  Inferno SRPT08 Use and Care Manual  Elite pliable Pt - Fitness Boutique      取扱説明書  取扱説明書2V2コントローラー  Yamaha 2004 Warrior Owner's Manual    

Copyright © All rights reserved.
Failed to retrieve file