INTRODUCTION TO DRAWING WITH LOGO

A Laboratory Exercise

By

Robert Byerly and Gary A. Harris

Department of Mathematics

Texas Tech University

Lubbock, Texas 79409

byerly @ math.ttu.edu & g.harris @ ttu.edu

Load LOGO, the method will vary according to your local platform. Any valid LOGO command will cause the graphics window to appear. Try the command st (L0GO itself is not case sensitive so ST works just as well.) and press the return key. Adjust your windows so that both the command line and graphics windows are fully exposed. (Change the position but not the size or shape of the graphics window.)

The little triangle (wedge, or pointer if you wish) is called the turtle. Its home is the center of the graphics window facing due north (up). In the command ST the "S" stands for "show", what do you think the "T" stands for? What do you think HT might stand for? Try it then ST again.

Think of the turtle crawling around the screen with an ink pen attached to its tail and experiment with each of the following command sequences. Pressing the return key produces the corresponding effects. In each case below describe the effect produced by the command sequence and state what you think the command is an abbreviation for. Note the spacing is important!

(If you draw a line you don't want, try erasing it with the command PE, pen erase, followed by reversing the command which drew the line in the first place. Of course after doing this you must turn the pen back to the drawing position before any more lines can be drawn. The command for doing this is PPT , pen paint.)

FD 100

RT 90

FD 100

HOME

LT 90

BK 100

RT 90 FD 100

LT 30 FD 100

LT 120 FD 100

LT 75

FD 200 (Oops)

PE BK 200 PPT

FD 141.42

HT

Sketch the resulting picture.

Indicate with arrows, the path the turtle took to draw this picture. Does this represent a traversable network?

Explain.

Explain where the number 141.42 came from. (Hint: the answer lies in ancient Greece.)

Continue the exercise with the following command sequences:

CS

ST

PU FD 100

RT 90

Continue from here to list a sequence of commands that draws the following picture with no line being traced more than once.

Congratulations you have just written your first program in LOGO. To celebrate let's draw an appropriate picture. Continue the exercise as above.

CS ST

PU SETXY 0 -150 PD

LABEL "put your first name here without spaces

PU HOME PD

ARC 360 100

RT 120

ARC 120 50

PU SETXY 40 40

PD ARC 360 10

PU SETXY -40 40

Provide the command sequence to finish the picture.

Continue the exercise as above.

CS

SETXY 100 200

SETXY 100 -200

SETXY -100 200

SETXY -100 -200

HOME

Sketch the resulting picture.

The following exercises show us that LOGO has calculating capabilities in addition to it's graphing interface. In fact, as seen in some of the exercises, calculations can be used in conjunction with the graphing commands.

2+2

PRINT 2+2

SQRT 4

PRINT SQRT 4

FD SQRT 2500

POWER 10 3

PRINT POWER 10 3

RT 30 FD POWER 10 2

RT 30 BK POWER 10 3

RT 360-90

SIN 45

PRINT SIN 45

ARCTAN 1

PRINT ARCTAN 1

LT ARCTAN 1

FD 100*SIN 45

PRINT SQRT ((POWER 10 2)+(POWER 10 2))

Multiple commands can be put on the same command line separated by spaces and executed by a single pressing of the return key.

Sketch the result of the following command sequence:

HOME CS RT 45 FD 100 LT 90 FD 100 HOME

Now fill in the missing commands to draw a right triangle "in general position."

FD 100 RT 90 FD 100

RT

FD

This sequence is called a "program," actually we will be more likely to call this kind of program, one which does a single specific thing wherever we might wish, a "procedure." The term "program" will then be used to refer to a list of commands, including such procedures in the list, needed to draw more complicated pictures.

Repeat the above exercise (right triangle in general position) with the following beginning command sequence:

FD 100 RT 90 FD 130

RT

FD

In each of the following exercises write a "procedure/program" which produces the given object. Also no other marks should appear on the screen, including the turtle.

1.Equilateral triangle

2. Square

3. Pentagon

4. Octagon

5. Regular 5 pointed star

6. Regular 7 pointed star

7. Four stacked circles

Notice how some of the above had the same simple command sequence repeated a number of times. There is a built in shortcut for writing such programs. Sketch the effect of the following command:

REPEAT 4[RT 90 FD 100]

8. Regular 20 sided polygon

9. Using the REPEAT command provide the "one statement" command which produces each of the above figures

1.	2.

3.	4.

5.	6.

7.