
Fall 2004
22C:151 Introduction to Computer Graphics
Assignment 4
Due: On paper at the beginning of class on Thursday September 23th
Goal: Get a feel for matrices and how they are used and applied in OpenGL.
Problem 1 (10 points): Write down the following matrices in two ways: (1) the standard 4×4matrix notation and
(2) as the one dimensional 16-entry array used in OpenGL.
•A matrix for translation by 5 in x, -3 in y, and 6 in z.
•A matrix for scaling by a factor of 2 in x, 0.5 in y, and 9 in z.
•A matrix for rotation of 90◦around the z-axis
•A matrix for rotation of 60◦around the axis ~r = (1,1,1)
•A projection matrix (i.e., to set up a camera’s perspective) for a viewing frustum with a field of view of 90◦, an
aspect ratio of 4
3, a near plane at distance 1, and a far plane at distance 100.
Problem 2 (10 points): For each of the following cases, draw (on paper) 3 images. One of the initial geometry, one
after the first transformation has been applied, and one after both transformations have been applied.
•Triangle with vertices at (1,1), (3,1), and (2,4)
1. Translate in xby 2 units and in yby -1 unit.
2. Scale in xby a factor of 2 and scale in yby a factor of 3.
•Traiangle with vertices at (1,1), (3,1), and (2,4)
1. Scale in xby a factor of 2 and scale in yby a factor of 3.
2. Translate in xby 2 units and in yby -1 unit.
•Quadrilateral with vertices at (1,1), (-1,1), (-1,-1), and (1,-1)
1. Rotate around z-axis by 45◦.
2. Scale by 2 in both xand y.
•Quadrilateral with vertices at (1,1), (-1,1), (-1,-1), and (1,-1)
1. Scale by 2 in both xand y.
2. Rotate around z-axis by 45◦.
•Quadrilateral with vertices at (1,1), (-1,1), (-1,-1), and (1,-1)
1. Rotate around z-axis by 45◦.
2. Translate by 2 in both xand y.
•Quadrilateral with vertices at (1,1), (-1,1), (-1,-1), and (1,-1)
1. Translate by 2 in both xand y.
2. Rotate around the z-axis (pointing out of the paper) by 45◦.
NOTE: Do not post your answers on your web page (for obvious reasons).