Sunday, 29 December 2013

Learning simple maths with shapes

If you were to ask a kid to draw a square and they would effortlessly get it done. Have you ever wonder if they really understand the definition of a square ?? Or a triangle ??  Getting things done is one thing, being able to describe or communicate effectively to another is a different story all together.

There is no doubt programming requires the use of logic, mathematical literacy and a little common sense, yet communication skill plays an important part to deliver clear and precise instructions in order for the computer to carry out the intended task.

How does math comes into picture with shapes ??
We all know that a closed shape has 360 deg, if we divide 360 by the number of sides of a shape, for example a square which has 4 sides, that will give you 90 deg on each side.
So, definition of a square is "a shape having 4 equal sides with 90 deg at each corner of the 4 sides".

Try working out a pentagon, triangle or a hexagon with your kids.  

Let’s start Scratch to draw a square. Get yourself familiar with the following blocks where we will be using it for our assignment.



You might like to shrink the sprite to see clearer how the lines are drawn. Drawing lines in computer sense means moving an object leaving a trail, and that’s where the “pen” blocks come into play.

Let’s work out a sequence for the script based on a flow chart before we snap the blocks together.


This is how the flow chart interprets :
  1.  Clear all the lines whenever the program starts
  2.  Draw the square beginning at position x = 0, y = 0
  3.  “Get” the pen
  4.  Move 100 steps
  5. Turn 90 deg to the right
  6. Repeat step (4) and step (5) 3 more times
  7. “Keep” the pen when finished drawing

Take note of the loop. As a square has 4 sides, we only need to repeat the sides 4 times, unlike the “forever” loop covered in my previous post.

We can now snap the blocks as shown below and that completes our task.


Now, what if we want to draw a hexagon ???
Hmm……a hexagon has 6 sides and what’s the angle at each side ???
Divide 360 by 6 and that gives 60 deg.

Using the same script we had created, replace 4 with 6 in the “repeat” block and 120 deg in the “turn () degrees” block.  You should have something like below.


Try other shapes yourself like triangle, pentagon, etc. A closed shape is only valid if the number of repeats multiply by the angles should give you 360.


No comments:

Post a Comment