Showing posts with label Square. Show all posts
Showing posts with label Square. Show all posts

Saturday, February 28, 2015

A Scratch Project for Drawing Tangrams and Compound Figures


Here is my Scratch project that draws two sample tangrams and the compound figures from this assignment (using Pro-Bots) created for grade 5 students.

I have created 5 different procedures for drawing the 5 components of the tangram. Please note that this is just one way of coding the figures; there are multiple correct ways of writing the programs for the same.


The functions (procedures) that are used for drawing the various polygons in the tangram can be found under the blocks titled:
  • parallelogram
  • square
  • largeTriangle
  • medTriangle
  • smallTriangle

The functions (procedures) for the compound figures that use the square and the triangle can be found under the blocks titled:
  • Square+Triangle
  • Square+Triangle_2

The functions (procedures) for the compound figures using the parallelogram and the small triangles can be found under the blocks titled:
  • TriParall_1
  • TriParall_2

I have given the code for two tangrams here as samples: one is the Monk with No Foot from the famous "Two Monks Paradox" and the other is a tangram for a House. The functions (procedures) for these can be found under the blocks titled:
  • MonkNoFoot
  • HouseTangram



Note:   The various dimensions in the assignment for Pro-Bot have been multiplied by a factor of 10 in my Scratch project, as we are dealing with pixels here and not centimeters, as in the case of Pro-Bot. 


Thursday, July 31, 2014

Solutions: Art with Pro-Bot - A Soccer Game

The soccer game picture is a follow-up to the "Art with Pro-Bot: A Dancing Robot" exercise, with one of the figures being the exact same as the Dancing Robot and the other being its mirror image.


Let's name the figure on the left as Team A and the one on the right as Team B. You would recognize from the figure that both Team A and Team B share some parts in common, such as the head and the neck. So, it's easier for the programmer to write the code for these parts just once and store it as a procedure; it can then be used multiple times. 

// Proc 1 - procedure for the neck and head


Fd 1
Lt
Fd 1
Rt
Rpt 3 [
Fd 2
Rt
]
Fd 1





Team A:  


// Program written in Main and using the above procedure. The Start point is marked in the figure.


Rpt 4 [
Fd 10
Bk 4
Rt
]
Fd 3
Lt
Proc 1


Team B:


// Program written in Main and using the above procedure. The Start point is marked in the figure.


Rpt 4 [
Fd 10
Bk 4
Lt
]
Fd 3
Rt
Proc 1


Art with Pro-Bot: A Soccer Game


Let’s use Pro-Bot to draw a picture of robots playing soccer.

We shall work using both Repeat Loops and Procedures in Pro-Bot for this assignment. This "art" project was designed to use the concepts of Repeat Loops and Procedures in a fun way.

There are 2 robots in the picture, one representing Team 1 and the other, Team 2. The two robots are playing each other in a game of soccer. The dimensions are as follows: Each robot's body is a 6 cm side square, the limbs are 4 cm long, the neck is 1 cm long and the head is a 2 cm side square. 

While writing the programs for Pro-Bot to draw the figures, remember to use Repeat Loops for patterns that repeat. You can also see from the pictures that the head and neck is exactly the same for both pictures. Hence, you can write the program for the head and neck once, store it as a procedure in Pro-Bot's memory and call it for drawing both robots. 

Click here for a set of solutions.

Draw in as many members for each team as you like. You can even store the programs for each robot as separate procedures which makes it easier for you to draw multiple figures in your art project. You can put in a background of your choice and draw a soccer ball in the middle once you have drawn both teams. It does not have to be just soccer; students in my class have used this theme to depict scenes from various sporting events. We worked on this project the day after a major basketball game and there were quite a few children who made pictures with basketball scenes... Let your imagination run free in creating your art work. 























Tuesday, July 29, 2014

Solution: A Train using Nested Loops

1.  Assume we start drawing the train from the leftmost bottom corner, with Pro-Bot facing forward.

Here is the code for the engine:

  Fd 6
  Rt
  Fd 2
  Lt
  Fd 3
  Rt
  Fd 2
  Rt
  Fd 3
  Lt
  Fd 6
  Rt
  Fd 6
  Rt
  Fd 10
  Bk 12
  Rt

At this point, the engine is done and the Pro-Bot is ready to start drawing the coaches. The 3 coaches are similar, which means we can use Nested Loops for drawing them. Here is the code for the train with 3 coaches and the connectors:

  Rpt 3 [           // the 3 here refers to the number of coaches
  Rpt 3 [           // the 3 here refers to the 3 sides of the square that forms a coach
  Fd 6
  Rt
  ]
  Fd 6
  Bk 8
  Rt
  ]



2.  To draw the train with 5 coaches, the only change required is to change the 3 in the outer loop to 5. The code for the engine remains the same. The code for the coaches is now:

  Rpt 5 [           // the 5 here refers to the number of coaches
  Rpt 3 [           // the 3 here refers to the 3 sides of the square that forms a coach
  Fd 6
  Rt
  ]
  Fd 6
  Bk 8
  Rt
  ]



3.  To draw the train with 20 coaches, the only change required is to change the number in the outer loop to 20. Everything else remains the same.

  Rpt 20 [         // the 20 here refers to the number of coaches
  Rpt 3 [           // the 3 here refers to the 3 sides of the square that forms a coach
  Fd 6
  Rt
  ]
  Fd 6
  Bk 8
  Rt
  ]

Art with Pro-Bot: A Train using Nested Loops

Using Pro Bot, trace the following simplified picture of a train. We have an engine up front and 3 coaches following it. The specifications for the engine and the coaches are provided below. All measurements are in centimeters.


Each coach is a square of side 6 cm.
The engine is 10 cm long and 6 cm tall. The funnel is located at 2 cm from the front end of the engine, and is 2 cm wide and 3 cm tall.
The connector between the engine & the first coach, as well as the ones between coaches are 2 cm each. We also have an extra connector on the last coach to account for any additional coaches that may be added in later.






















In this project, we shall:
(1) work with nested loops
(2) revisit the technique to draw squares using Repeat Loops
(3) think about how to customize our code to produce a new train picture with a varying number of coaches each time.



  • Write a program for Pro-Bot to draw the above picture of a train with the engine and 3 coaches. Remember to use Nested loops in your program.
  • Now modify your program so that Pro-Bot draws a similar train with the same engine and 5 coaches. What changes did you make to your program?
  • What change would you make to your program if you want Pro-Bot to draw the above train with 20 coaches?
  • Once you have drawn the picture of the above train using Pro-Bot, you can decorate your picture and give it an interesting background.

I had designed this project as a fun way of introducing Nested Loops to the children. We worked on this project the week of Valentine's Day. So, after drawing the train using Pro-Bot, we had fun customizing the train picture to the theme, with little heart shaped stickers chugging out of the funnel. Each kid drew a picture of himself/herself as the train driver and their family in the train's coaches, with backgrounds of their choice... It was a really fun assignment. Across the various classrooms that I taught, children ranked Nested Loops as the most favorite programming concept that they learned this year.


Here is a set of solutions to the above.


Solutions: Art with Pro-Bot - A Dancing Robot

The picture of the Dancing Robot consists of 2 main parts - the body and the head, both of which are squares and can be drawn using Repeat Loops. The interesting part is that the limbs of the robot can also be drawn as part of the Repeat Loop for drawing the body.




Let's look at the code for drawing the body of the robot first. Please keep in mind that depending on the starting point and the direction in which Pro-Bot is facing, you can have different ways of drawing this figure.


Here is one way of drawing it, refer to the figure on the right for the Starting point.

    Rpt 4 [
    Fd 10       // body + limb = 10 cm
    Bk 4          
    Rt        
    ]




Now, let's try to draw the neck and the head of the robot. Again, the following code is just one of the possible solutions.

Starting from the neck and going up,

    Fd 1          // 1 cm long neck
    Lt
    Fd 1
    Rt
    Rpt 4 [      // Repeat loop to draw the square for the head
    Fd 2
    Rt
    ]
 

Combining the two pieces of code above, we have the final program to draw our dancing robot:
 
    Rpt 4 [      // Start by drawing the body of the robot
    Fd 10    
    Bk 4          
    Rt        
    ]
    Fd 3         // After drawing the body, get to the start point for drawing the neck
    Lt
    Fd 1          // Draw the 1 cm long neck
    Lt
    Fd 1
    Rt
    Rpt 4 [      // Draw the square for the head
    Fd 2
    Rt
    ]



Art with Pro-Bot: A Dancing Robot



Write a program to draw the following figure of a dancing robot. All measurements are in centimeters. 

Do you see patterns in the figure that keeps repeating? How many Repeat Loops can you use in the program for this robot?

The sides of the body are 6 cm long, the limbs are 4 cm each. The neck is 1 cm long and the head is a square measuring 2 cm on each side.






















This assignment can be used as a follow-up to drawing squares with Repeat Loops. The body of the robot can be written using a Repeat Loop as can the head. 

The children in the classes that I taught drew multiple ones of these and drew in other features by hand. Imaginations ranged all the way from groups of ballet dancers to soccer players to swimmers (with the picture rotated to the right)...

Click here to see one set of solutions.

Solutions: Art with Pro-Bot - Snails

Let's create four procedures for the squares of sides 2 cm, 4 cm, 8 cm and 12 cm. We could store them in Proc 1, Proc 2, Proc 3 and Proc 4.


Here is one way of writing these procedures:

// Proc 1 - procedure for drawing 2 cm side square
Rpt 4 [
Fd 2
Rt
]


// Proc 2 - procedure for drawing 4 cm side square
Rpt 4 [
Fd 4
Rt
]


// Proc 3 - procedure for drawing 8 cm side square
Rpt 4 [
Fd 8
Rt
]


// Proc 4 - procedure for drawing 12 cm side square
Rpt 4 [
Fd 12
Rt
]



Next, we shall use the above procedures to draw the snails. Keep in mind that this is just a subset of the possible solutions. Both the procedures as well as the following programs can be written in multiple ways.

Program for the small snail as written from Main:


Proc 1
Rt
Fd 4
Lt
Proc 2
Rt
Fd 1
Lt
Proc 1


Program for the large snail as written from Main:


Proc 2
Rt
Fd 8
Lt
Proc 4
Rt
Fd 2
Lt
Proc 3
Rt
Fd 2
Lt
Proc 2



Art with Pro-Bot: Snails

Write a program for Pro-Bot to draw a picture of snails as shown below. 

The bigger snail has a square head of side 4 cm and a 4 cm long neck. The outer square of its shell has 12 cm sides, the middle one 8 cm & the inner one 4 cm. The smaller snail has a square head of side 2 cm & a 2 cm long neck. The outer square of its shell has 4 cm sides & the inner one 2 cm.


Remember to use Repeat Loops when you write programs for drawing squares using Pro-Bot. We shall reuse the pattern for the larger snail's shell from the Repeat Loops Maze project. 



Once you are done drawing the body of the snail using Pro-Bot, you can draw in other features such as eyes, mouth, antennae, etc. You can also draw in more features in the background to make your picture more interesting. 

























I designed this project to let the children practice Repeat Loops and Procedures in a fun way using Pro-Bot. Repeat Loops were used for drawing the squares. The 4 cm side square was stored as a procedure and used multiple times in the figure. We did the same for the 2 cm side square as well. 


Here is a set of solutions.


Solutions: Art with Pro-Bot - Snowmen

Let's first write the programs for the squares of sides 6 cm, 4 cm and 2 cm.  We shall store these are three different procedures, say in Proc1, Proc2 and Proc 3.

Here is one way of writing the programs:


Proc 1      // procedure for 6 cm side square
Rpt 4 [
Fd 6
Rt
]


Proc 2      // procedure for 4 cm side square
Rpt 4 [
Fd 4
Rt
]


Proc 3      // procedure for 2 cm side square
Rpt 4 [
Fd 2
Rt
]



Now let's draw the small snowman using the above procedures. From Main, the program shall be written as:


// Program for the Small Snowman


Proc 2
Fd 4
Rt
Fd 1
Lt
Proc 3


You can use the above procedures for drawing the large snowman as well. From Main, the program for the large snowman can be written as:


// Program for the Large Snowman


Proc 1
Fd 6
Rt
Fd 1
Lt
Proc 2
Fd 4
Rt
Fd 1
Lt
Proc 3









Art with Pro-Bot: Snowmen


Write a program for Pro-Bot to draw some snowmen using three different sized squares. The squares have sides measuring 6 cm, 4 cm and 2 cm. Remember to use Repeat Loops while programming the squares. Draw in other features by hand for the snowmen (eyes, nose, mouth, scarf, hat, etc.) after you draw the snowmen’s bodies using Pro Bot.

























I designed this "art" project to allow the children to practice using Procedures as well as Repeat Loops. The squares were all drawn using Repeat Loops. The 4 cm side square and the 2 cm side square were stored as Procedures and reused in the figures. In fact, they can be even reused for other projects, like the Snails.

Some of the children imagined these to be wedding cakes instead of snowmen and drew in features accordingly... There was even a picture of a snowman eating a two-tiered cake.


Here is a set of solutions to the above.