0% found this document useful (0 votes)
82 views5 pages

Chapter 15

This document describes how to modify the Logo poly procedure to create a spiral drawing procedure called spi. It explains that by increasing the forward step on each iteration, the turtle will draw a spiral shape. The poly procedure is edited to become spi by changing the name and recursion line to increment the step value by 2 each time. Finally, the spi procedure is modified again to allow specifying the increment amount as a third input parameter.

Uploaded by

Cynthia Solomon
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views5 pages

Chapter 15

This document describes how to modify the Logo poly procedure to create a spiral drawing procedure called spi. It explains that by increasing the forward step on each iteration, the turtle will draw a spiral shape. The poly procedure is edited to become spi by changing the name and recursion line to increment the step value by 2 each time. Finally, the spi procedure is modified again to allow specifying the increment amount as a third input parameter.

Uploaded by

Cynthia Solomon
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Chapter 15 Some More Advanced Techniques: Spirals

Some More Advanced Techniques: Spirals


The p o l y procedure makes the turtle draw closed figures. An exception occurs when the turtle turns 0 or 360 degrees (or a multiple of 360) on each round. Then, it walks in a straight line.
TO P O L Y : S T E P : A N G L E FD : S T E P RT : A N G L E POLY : S T E P : ANGLE END

STEP ER ANCLE

ANCLE

STEP EP

ANCLE

ANCLt

The turtle draws closed figures because it goes forward and rotates a fixed amount and it eventu ally gets back to where it started. We can easily have the turtle draw a spiral by increasing its for ward step on each round of the procedure. Lets change p o l y and name it s p i and thus make a spi ral drawing procedure.
EDIT"POLY

Now the Logo editor shows the


TO P O L Y : S T E P : A N G L E FD : S T E P RT : A N G L E POLY : STEP : ANGL E END

po l y

procedure.

.S T E P 2

ANCLE ANCLE

Now change the name of the procedure from p o l to SPI.


TO S P I : S T E P : A N G L E FD : S T E P RT : A N G L E S P I : STEP : ANGLE END

103

We make one more change to the recursion line. We tell s p i to add 2 steps to :s t e p . Thus,
TO S P I : S T E P : A N G L E FD : S T E P RT : A N G L E S P I : STEP + 2 : ANGLE END

Now

try

s pi

n in
S P I 5 90 SP I 5 120 _ _ t c- i a SPI 5 60
Remember
c trl-g

stops.

CTRL-L s h o w s t h e w h o le t u r t l e

field.

u,

SPI SPI SPI

5 144 5 125 5 160

Try s p i with other inputs. Change s p i and give it a third input, :i n c , which s p i will add to :s t e p in stead of 2. Then you can change how much the turtles step increases by choosing different num bers for the third input.
ED "SPI

The Logo editor shows this procedure.


TO S P I : S T E P : A N G L E FD : S T E P RT : A N G L E S P I : S TEP + 2 : ANGLE END

104

Now change the procedure so that it looks like this.


TO S P I : S T E P : A N G L E : I NC FD : S T E P RT : A N G L E S P I : S T E P + : I NC : A N G L E : I NC END

Now try

SPI

5 75

You might want to stop the turtle at different places. Try other inputs.

You might also like