This week we will practice decomposition, pattern matching, and algorithm design by creating an R script to draw simple figures. And we learn the discipline to deliver homework always on time, even if it is not ready.
Using R Turtle Graphics, write programs to draw:
- A pentagon
- A polygon of N sides
- A house
- A person
Some people may prefer to do these exercises in Scratch first, and then translate them to R. The exercises are ordered from easiest to hardest. Notice that the house is made with triangles, squares and rectangles.
You get extra points if you improve the examples. The house can be much better, and the person does not need to look like a robot.
Each exercise can be done independently in the same file. It is a
good idea to define some functions to use later, such as
draw_polygon(corners, length). This is optional,
although it is recommended.
Your answer must be an R file. Please download the
edit it with RStudio. Make sure that the file ends with
and not with
.txt. Sometimes Windows changes the file
extension and things do not work. In that case you may need to Save
as… and write the correct file name.
Write your student number in the email’s Subject and in the
first lines of the file. Send the file to