Workbook 4: Transformation Math

Spring 2025 Sample Solution

This is a sample solution for the Workbook. You are welcome to refer to it to learn one way to do the assignment but only after you have turned in your own assignment

Last time, we learned about transformations and coordinate systems. We learned a few transformations (translate, scale and rotate), how to think about transformations as changes of coordinate systems, and some ways we use transformations (e.g., to build hierarchy or create convenient coordinate systems). This week we’ll learn about how they work mathematically.

We will start by looking at a notational reason why our math (or the math in a textbook) looks different than the code we write for the Canvas API. We will then look at the general math for transformations as well as the special, simple case of linear transformations. Linear transformations are the most common case in graphics - and include all of the transformations we’ve discussed so far. Then we can dive into the math of linear transformations (although, the textbooks cover this well). As part of this, we’ll look at a common graphics trick of using homogeneous coordinates which will allow us to represent translation as a linear transformation. When we get to 3D, this will let us do other things as well.

Also, as part of this workbook, we’ll experiment with a fun animation technique as a way to practice vector algebra.

The mathematical nature of this material doesn’t lend itself to the workbook format. So some of the exercises may seem a little contrived. Do the exercises by implementing the things we ask, not by just typing in the answers.

You will only need to edit the files in the for_students directory. Don’t forget to commit and push your work. And please remember to complete the WB4 Workbook Form when you are done so that your assignment is ready for grading.

Note: There is a big programming assignment on Lots of Walking Objects (Page 5)

Reading / Watching

This is a topic where the textbooks do a good job at introducing the material. You don’t have to read these right now - you can read them as they come up in the workbook, and we’ll link to them throughout.

I was trying to avoid requiring students to read from textbooks, but this is a place where they are really helpful. You need some place where they write the equations out in a formal way. But before you get to that, you probably need to be motivated why you want to know this stuff. This workbook, and the Washington videos, hopefully provide that motivation.

Required:

Optional:

Assessment

The graders will check that you have done the required programs correctly. We’ll use a local server for grading your workbooks.

As you go through the workbook pages, feel free to tinker with the programs we have given you as a way to understand how they work!

There are opportunities for advanced points on page 5.

Get Started

Don’t forget to commit and push as you work!

Workbook Rubric (10 basic + 8 advanced (6 max) = 16 total)
Box Basic Advanced Description
1 correct WB4 Workbook Form submission on time
04-02-01 filled in correct answer
04-02-02 filled in correct answer
04-02-03 filled in correct answer
04-02-04 filled in correct answer
04-02-05 filled in correct answer
04-02-06 filled in correct answer
04-02-07 filled in correct answer
04-03-02 filled in correct answer for 3 matrices
04-04-01 red dot stays in red corner and black dot stays in black corner as dots are dragged; square remains square; done via translate, rotate, and scale
04-04-02 red dot stays in red corner and black dot stays in black corner as dots are dragged; square remains square; done via transform
04-04-03 red dot stays in red corner and green dot stays in green corner as dots are dragged; square remains square
04-04-04 parameters changed so that square 1 matches
04-04-04 parameters changed so that square 2 matches (freebie!)
04-04-04 parameters changed so that square 3 matches
04-04-04 parameters changed so that square 4 matches
04-04-04 parameters changed so that square 5 matches
04-04-05 shear-x implemented to draw sheared squares
04-05-01 boids - add 10 boids when button is clicked, random locations and directions (but all with the correct speed)
04-05-01 1 boids - clear when button is clicked
04-05-01 1 draw boids so the direction they are facing is clear
04-05-01 1 boids bounce, not wrap
04-05-01 1 boids change color (briefly) when they hit a wall
04-05-01 1 boids bounce off each other
04-05-01 1 boids change color (briefly) when they hit another boid (either overlap or come very close)
04-05-01 1 boids has at least 4 legs like ants or spiders
04-05-01 1 boids has legs that move while they move
04-05-01 1 boids randomly make infrequent small changes in direction while walking
04-05-01 1 cool or more realistic movements of the legs
04-05-01 1 boids leave a trail that fades and disappears
04-05-01 1 boids bounce off obstacles
04-05-01 1 visually obvious alignment flocking behavior
04-05-01 1 visually obvious separation flocking behavior
04-05-01 1 visually obvious cohesion flocking behavior
04-05-01 1 visually obvious mouse attraction flocking behavior
04-05-01 1 added slider or checkbox that alters steering behavior

Get Started on Page  1  (Transformations as Math vs. Code)!