Transformations

Lesson #15 Transformations and Tessellations
Initial lesson Post date - November 3, 2012 Revision date - Fall 2017

** Purpose: ** This final lesson in **Learning Geometry with Logo**, introduces the transformations; rotation, reflection and translation. Polar coordinates are introduced in the discussion of a translation vector. ** Essential Questions: ** What information is necessary to turn, slide or flip an image and how can these movements (transformations) be coded in Logo? A Section of the Lesson Follows

A **rotation** requires three pieces of information. The design shown in figure 15.1 is a flag drawn with right turns. The direction of turn is clockwise. The rotated flags in figures 15.2 and 15.3 use (0, 0) as the center of rotation. In each figure, the flag with the vertical post (seth 0) is called the **preimage**.
 * 1) A center of rotation
 * 2) The degrees of turn
 * 3) The direction of the turn

The rotated flag graphics were created with a main calling procedure titled Rotate. The Rotate procedure needs one input value that will indicate the degree of rotation symmetry. If the input value is 3, the rotation is 120 degrees, because 360/3 = 120 degrees [recall lesson 1]. Logo Code: TO FLAG FD 100 RT 135 FD (50 * SQRT (2)) RT 135 FD 50 LT 90 FD 50 LT 180

TO ROTATE X REPEAT X [FLAG RT 360 / X]

Do not forget to type a value for x when running the TO ROTATE Procedure! The figures above show the pre-image, the 120 degree rotation and the 60 degree rotation.

A **reflection** requires one piece of information, a **line of reflection**, often called a **mirror**. In the first example, the mirror is a vertical line through the point (0, 0) [the y-axis]. The second example uses a slanted line through (0, 0) as the mirror. Note that the line of reflection has a slope of 1. The reflected flag graphic (figure 15.4) was created with a procedure called Flip. The turtled was slowed down so you can watch as the shape is drawn. Note that I was able to use the Flag routine for the pre-image on the right (first turn is right) but I had to rewrite the Logo code to draw the flag on the left (first turn is left so it moves in a counterclockwise direction). This indicates that a reflection will change the orientation of the points as you move around the shape.
 * [[image:Flag Flip.png align="center"]]

Figure 15.4 || ** Logo Code for Flip Procedure **  || HOME SLOWTURTLE FD 600 PU SETXY [50 0] PD FLAG PU SETXY [-50 0] PD FD 100 LT 135 FD (50 * SQRT (2)) LT 135 FD 50 RT 90 FD 50 PU END || over the line y=x ||  ||
 * ^  || TO FLIP
 * Omitted Figure 15.5 and Logo Code for Flip

** Polar coordinates ** describe a position on the plane in terms of the distance from the turtle's home in the center of the Graphics window and the angle from 0 degrees. Polar coordinates measure degrees counter-clockwise from a 0 degree heading that is equivalent to 3 o'clock. //Retrieved from: Terrapin Logo Help | Commands | setp// Think of combining the ** forward ** and the ** setheading ** commands into one Logo command. The **setp** command draws a vector. A vector has two components, **magnitude** and **direction** (in polar coordinates). The syntax is **setp magnitude direction.** The example **setp 100 90** will move the turtle 100 steps straight up.
 * New Command: **

In Logo, there are at least three different command sequences that will draw the same vector. Figures 15.7 and 15.8 illustrate two different vectors. seth -300 fd 100 || A **translation** (slide) requires two pieces of information, the direction and length. The translations shown here begin at the origin. The translation shown in Figure 15.8 moves 100 steps at a 0 degree heading (polar direction). The translation shown in Figure 15.9, moves 100 steps at a 135 degree heading (polar direction).
 * Turtle Moves up and to the Left ||  Turtle moves up and to the Right  ||
 * setp 100 135  seth -45 fd 100   seth 315 fd 100  ||  setp 100 60  seth 60 fd 100
 * [[image:Logo setp.png width="410" height="281"]]Figure 15.6 || Omitted Figure 15.7 ||
 * ** Translation to the Right ** ||  ** Logo Code for Slide Procedure **  ||
 * [[image:slide.png align="center"]]

Figure 15.8 || TO SLIDE SETXY [0 0] SETWIDTH 2 FLAG SETP 100 0 SETWIDTH 4 FLAG HT END ||


 * ** Translation Up and to the Left ** ||  ** Logo Code for Slide 2 Procedure **  ||
 * [[image:Slide2.png align="center"]]

Figure 15.9 || TO SLIDE2 SETXY [0 0] SETWIDTH 2 FLAG SETP 100 135 SETWIDTH 4 FLAG HT END ||