Thursday, January 14, 2021

Scalene Triangle Mouse Using the Law of Cosines

   In the December 21, 2020 post (Coding Math Concepts as Tests of Student Comprehension) I presented the problem of coding a scalene triangle as a challenge considerably tougher than just learning the definition of a scalene triangle and examining a few triangles.
   I felt there was a crudeness to the method I used and even published an Addendum December 23, 2020 (Addendum to Scalene Triangle Mouse I) that 'fixed' the heading problem presented by the go to that drew the third leg. In this post, I offer another method for drawing a scalene triangle that uses the law of cosines taught in s first trigonometry course.

   The method is straight forward and essentially requires coding the angle formulas shown in the following diagram since the program asks the user to set the lengths of the three sides to different values (the definition).

   Teachers and students might be interested in the free PDF file that describes the Scratch program in more detail. If interested, send an email requesting Scalene Triangle Mouse II and I will end you a copy that holds no copyright. I will also send upon request the Word file that can be changed if you don't have Adobe.

Monday, January 11, 2021

Using Lists in Scratch - Singe Die Frequencies

    Scratch is a descendent of the Logo programming language that was developed by Dr. Seymour Papert at the the Artificial Lab at MIT. Logo had elements of the LISP programming language popular at the Lab at that time. LISP is an acronym for LIStProcessing and used data structures called lists. 
   To illustrate the use of lists I've written a PDF document that uses lists to store the frequency of the results of throwing a single die a number of times. Assuming the die is a fair die, the frequency of each of the numbered faces, 1, 2, 3, 4, 5 and 6 should be equal for say 6 throws, 36 throws, and 216 throws. Here is the Scratch script.

   Below is a screenshot of the display produced by the above script for six rolls of a single die. Note that the program does not produce the theoretical values of the frequency of 1 for each of the six possibilities. Bit neither does six rolls of a real die.
   If you are a teacher or a students and would like a free copy of the PDF file that details the building of the script just email your request to
   A more advanced project that uses lists to record the frequency of the sum of a pair of dice for a repeated number of throws will be the topic of a future post.

Wednesday, December 23, 2020

Addendum to Scalene Triangle Mouse I

   At the conclusion of the Coding the Scalene Triangle Mouse I document, I described what I considered to be a flaw in the code; when completing the third leg of the triangle the mouse did not actually point to the starting point of the triangle but moved in a skewed fashion.
   Scratch does contain a [point towards (mouse-pointer or another sprite)] block. 

   I suppose one could make the starting point of the triangle a small circular sprite and then simply ‘point to it’ to draw the third leg of the triangle. I call this approach a work-around as it solves the problem for the present but when time allows a more elegant solution will be found. So I thought about how to create code that will point the mouse from one point to any other specified point. In other words, I wanted to code a generalized solution. It turns out that the basic trigonometry operator, tangent (angle) abbreviated tan(angle) helps to solve the problem.
   In Scratch, the tan operator (see below) returns the numerical ratio of the opposite side over adjacent side as shown in the diagram above. 
   The arctan operator takes the numerical ratio and returns the angle.
   For example, for a 38º angle, tan 38º = 0.7812 and the arctan of 0.7812 = 38º

     In the diagram below the xpos and ypos reporters in Scratch return the values for x2 and y2. The values for x1 and y1 are set in the code. These values are used to compute the tangent of the angle and then the arctangent operator computes the value in degrees of the angle. The mouse can then be turned to the left through the angle (90º – angle)  to be pointed directly towards the point (x1, y1).
  I have written a detailed tutorial describing the coding of the above addendum to the Scalene Mouse Triangle project. A free PDF file of this document that might be useful to both teachers and students can be obtained by emailing me at

Monday, December 21, 2020

Pen Commands in Scratch 3

   Go to and click on Create in the upper left corner. The Editor page, shown below, will open. This version is Scratch 3. Earlier versions of Scratch had a Pen tab listed with the other colored categories of blocks. Scratch 3 has moved the Pen commands. 
   To find them, note the small blue block in the lower left of the Scratch home screen. The blue icon indicates additional blocks. Click on the blue icon and a page of additonal commands are revealed. 

   Click on the Pen icon in the lower left corner of the above menu to reveal a page of options. Choose the option Pen.
   Click on Pen as pictured above to reveal the list of Pen Commands as we knew them in Scratch 1 and Scratch 2.

    If you use Pen commands in a project, every time you open the project the Pen icon will appear under the My Blocks menu icon.

   A copy of this post in PDF file format suitable for teacher or student use can be obtained, free of charge, by sending an email request to

Coding Math Concepts as Tests of Student Comprehension

    In Bloom's Taxonomy of Educational Objectives, a test of a learner's 'comprehension' of a concept is the ability of the learner to 'rephrase’ or ‘restate' the concept in as many different ways as possible. For several years I have been interested in using standard mathematics curriculum as a source of computer coding exercises in which students ‘rephrase’ math concepts. Geometry is an especially rich source for computer coding projects. In this post we use computer code to explore the scalene triangle concept.

Where to begin?

Scalene triangle: A triangle with three unequal side lengths and three unequal angle measures

The definition tells us how to recognize a scalene triangle if we know the lengths of the three sides.  But the definition is static, not dynamic. Typing the definition into computer code will code the individual letters (ASCI II) but the code simply displays the definition as text, not as a figure of a scalene triangle.

This is often a point of frustration with beginning programmers as they may know a ‘concept’ as a set of words or symbols but become frustrated when trying to code the concept.

To code a scalene triangle in Scratch is not a trivial exercise.

To begin, I’ve created a starter project that has a mouse as sprite 1. You can click on this link to download the project or create your own starter.

                                    Scalene Triangle Mouse Starter

   The completed project can be downloaded by clicking on the following link.

Scalene Triangle Mouse I

   I am in the process of writing a detailed tutorial describing the coding of the Scalene Triangle Mouse I project. A free PDF file of this document that might be useful to both teachers and students can be obtained by emailing me at

   The following projects are in the same spirit as each project codes a math concept.

Radian Mouse

Perpendicular Mouse

Parallel Mouse

Angle Mouse

Wednesday, September 9, 2020

Virtual Robotics


Robotics is a hot component of the STEM (Science, Technology, Engineering, Mathematics) movement. Several companies offer robotics hardware and software that supports educators and students.

One of the problems robotics educators face is that there is not an agreed upon sequence of knowledge requirements and a sequence of skill development as there is, for example, for mathematics and science education.

Years ago I watched a video on educational TV that was my introduction to robotics as a topic for educators. The program featured a mechanical engineering professor at MIT describing a project assigned to his freshman engineering students. Each pair of students were given a box of electric motors, gears, wheels and other small parts. The task was to build a robot controlled by a joystick. Students were shown in the machine shop drilling, grinding and wiring their robots. The project culminated in a King of the Mountain competetion. Students robots fought each other to stay at the crest of a hill for a given amount of time.

Along with the mechanical engineering standards he taught he also wanted his students to understand that every engineering task was always constrained by a least three limiting factors.

1. Time to complete the engineering project is not unlimited.
2. There is always a limit on the amount of money available to complete the project.
3. There is always something new that has to be learned.

Great information for men and women looking to become engineers

A teacher in east Russia has rekindled my interest in educational robotics and is the
inspiration for this blog post. As a teacher, Andrei is interested in Scratch and robotics.
Scratch is complete and free but robotics hardware is expensive. Most teachers do not have
the financial support to equip a classroom with several robots. Many teachers have just one
robot, often purchased with their own funds, to demonstrate to students.

In researching the latest robotics hardware and software I found a company, www.vex.comthat was new to me. Vex understands that not all teachers have the funds to invest in the robotics kits they sell. To help with this problem, Vex provides a' virtual' robot modeled after one of their hardware robots. The code used to control the virtual robot is the same code used to control the real robot.

Students that are working with one of the Vex hardware robots at school can now program at
home and test their code on the virtual robot. Students without a real robot can still program the virtual robot. Click on the following link to go to the Vex Virtual Robot.

Vr.vex runs in your browser so there is nothing to download. Those familiar with Scratch

will immediately recognize the Vr.vex home screen.

The 'blocks' snap together like Scratch blocks. Below is the code for a Spirolateral (see link
to my Spirolateral post below) that executes right turns only.

Te display screen is called a playground and specific playgrounds are selected from
a drop down menu. Below is the isometric view that displays a run of the above code.

In the following picture the top-down view is displayed.

   The Vr.vex website has several sample projects that offer robot problems to
solve. If you are interested in robotics, search the Vex website for both hardware and software products.

   Here are two Scratch-blog posts that have robotics as a theme.

Spirolaterals in Scratch

   Mark Johnson has the following videos on Youtube that are worth watching.

VEX VR Introduction-Square (VR Series Part 1)

VEX VR Variables (VR Series Part 2)

VEX VR Functions (VR Series Part 3)

VEX VR Basketball Drills (VR Series Part 4)

VEX VR Color Disk Transfer (VR Series Part 5)

VEX VR Dynamic Maze (VR Series Part 6)

   If interested, I have an academic paper on Spirolaterals that can be obtained free by sending an email request to

Sunday, April 30, 2017

Mathematical Discovery in Grade Two

   My original copy of Professor Seymour Papert’s book Mindstorms is packed away so I recently ordered a new copy from Amazon. I read the book when it first came out in the late 1970s and became an immediate convert to Papert’s vision for the computer as ‘an object to think with’. 
   As director of the MIT Artificial Intelligence Lab (now the MIT Media Lab) he and Wallace Feurzeig developed Logo, the first programming language designed with a entry level simple enough that kids could use it but robust enough for serious programming.
   Logo was available for the early Apple IIe and Atari 400/800 home computers. I used and taught several versions of Logo but I liked Atari Logo because it had a colorful ‘turtle’ as a cursor. 
   The Logo turtle is a mathematical object. In fact, it’s a vector object since it can be pushed or pulled in any direction. 

   Below is the simple code for drawing a square using Logo and the modern successor to Logo, Scratch.
   When home computers first became available I was a district math/science/computer coordinator with a limited amount of money to buy hardware and software. Just a handful of teachers were interested in ‘computers in the classroom’ and they were curious to learn what students could and would do if they had even limited access to a computer. Marty was one of those teachers and he pioneered Logo in his second grade classroom.
   Marty invited me to visit his class and observe students at the computer. Early one morning I arrived in his classroom as students were taking turns cycling through the single computer center. There they used the computer and Logo to draw squares, triangles, and hexagons and played with the color of the drawing pen.
   Marty had taught them that a ‘square corner’ was a turn of 90º and half of a square corner a turn of 45º. The students could then consult a chart that displayed turns as multiples of 45º. They also knew that a triangle needed a 120º turn and not a 60º turn.

   What follows is a description of what I observed one particular student do when given a turn at the computer. 
   To begin, the student typed clear to send the turtle (cursor) to the center of the screen, pointing North (see A in the diagram below).  The student then typed the first command, forward 100 right 90, followed by the return key, and the turtle moved and turned to the position shown in diagram B. The 90º angle indicated that the student was going to draw a square. The second command, forward 100 right 90, moved the turtle to the position shown in C. The third command moved the turtle to D and the fourth command to E, its starting point, with the turtle again facing North. The student had directed the turtle drawn a square.
   At this point I expected the student to clear the screen and draw another figure but the student hesitated. Why? What could the student be thinking? We cannot know what is going on inside another human’s head but, when the student commanded the turtle to right 45 (F) it flashed in my head that the student was thinking about crossing the square, from its lower left corner to its upper right corner. In other words, the student was pointing the turtle along the diagonal of the square!

   And the student's next command, forward 100, confirmed this as the turtle moved 100 units along the diagonal (G).
   But again, the student hesitated! Was the student surprised that the turtle didn’t make it to the upper right corner? All the previously drawn triangles, squares, and hexagons had formed closed, regular polygons.
   The student then typed forward 1 over and over until the turtle reached the upper right corner (H).
   The student then cleared the screen for the next student and returned to the student’s desk. 
   Clearing the computer’s screen had erased the history of this student’s discovery that the diagonal of a square is longer than the side of the square.
   During morning break I described for Marty how that one student had  ‘discovered’ that the diagonal of a square is longer than the side of the same square. We realized that we might be missing other examples of students using the turtle to ‘play’ with mathematics.  
   That afternoon we set up a video camera focused on the computer screen. Marty would turn on the camera any time students were in the computer center. Later, by reviewing the video, we could identify students that were not just practicing regular polygon construction but were using Logo as ‘an object to think with’.
   We found that several students would complete the computer center assignment and then use the remaining minutes to explore on their own. Marty and I were not researchers so we never wrote about the exciting mathematical learning experiences we captured on videotape.
   For Marty and myself, the experience amounted to an existence proof that Papert’s belief that students could use Logo as an ‘object to think with’ was true.
Chapter 3 of Mindstorms opens with the following:
“Turtle geometry is a different style of doing geometry, just as Euclid’s axiomatic style and Descarte’s analytic styles are different from one another. Euclid’s is a logical style. Descarte’s is an algebraic style. Turtle geometry is a computational style of geometry.”
Optional Challenge:
   Move and turn are primitives in both Logo and Scratch. These two primitives can be combined to program the turtle to draw a circle (actually a regular polygon with a large enough number of sides to make it look like a circle).
   To experience computational geometry, visit my Scratch blog by clicking on the following link 
and read a post that derives of a set of equations that use move and turn to draw any regular polygon. As the number of sides of the regular polygon increases, its perimeter approaches the circumference of the circumscribed circle.