Workbook 4: Transformation Math
CS559 Spring 2023 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
Learning Goals
- To understand how coordinate systems and transformations are represented mathematically
- To understand affine transformations and the use of homogeneous coordinates to represent them
- To be able to build transformation matrices based on the desired outcomes
- To be able to read a transformation matrix to understand what it does
- To understand how Canvas and SVG use matrices internally
- To use transformations in matrix form in graphics programs
- To practice graphics programming using vector math
- To get some exposure to JavaScript Object-Oriented Programming
- To try out the course framework code
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 Canvas Assignment 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:
- Affine Transformations in 5 Minutes and Hierarchical Modeling in 5 Minutes - These two videos introduce the basic concepts. They are from the University of Washington Graphics in 5 Minutes series. I am not sure they teach you everything you need to know, but they are great at motivating the details that you will need to read a textbook for.
- CS559 Tutorial: Points, Vectors, Coordinate Systems - something Professor Gleicher wrote that might help connect between math you probably have already read
- Sections 6.1 (but not 6.1.6) and 6.3 of Chapter 6 of Foundations of Computer Graphics (FCG)
Optional:
- Linear algebra refreshers: CS559 Tutorial: Linear Algebra for CS559.
- Sections 6.4 and 6.5 of Chapter 6 of FCG - two pieces that are optional for class, but helpful if you really want a deeper understanding.
- The online textbook Introduction to Computer Graphics - in particular the sections on Transforms and Hierarchical Modeling gives a “math last” introduction (although the code examples are Java).
Rubric for Grading
Workbook Rubric (103 points total)
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!