Overview
This card is designed to be printed and kept alongside your lab worksheet. It covers trig values at standard angles, the standard transformation matrices in column-major layout, and the GLM function calls that correspond to each matrix operation.
Learning Objectives
By the end of this lab you will be able to:
- Use this card as a quick reference during any lab from Lab 07 (Transformations) onward
- All matrices are shown in the row-reading convention used on paper; GLM stores them column-major internally but the mathematical content is identical
Concept
This reference card contains no exercises. Use it alongside worksheets WS-M02 through WS-M07 and the Transformations lab (Lab 07) onward. All matrices are written in the row-reading convention used on paper: each row is displayed left to right. GLM stores them in column-major order internally (first column occupies memory indices 0-3, second column 4-7, and so on), but the mathematical content is identical. You do not need to rearrange these matrices when writing GLM code. Refer to the Column-Major Convention lab (WS-M04) if you need a reminder of the storage layout.
Tasks
Task 1 - Reference Tables
Section 1 - Trigonometric Values at Standard Angles
| Angle (deg) | Angle (rad) | sin | cos | tan |
|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 |
| 30 | π/6 | 1/2 | √3/2 ≈ 0.866 | 1/√3 ≈ 0.577 |
| 45 | π/4 | √2/2 ≈ 0.707 | √2/2 ≈ 0.707 | 1 |
| 60 | π/3 | √3/2 ≈ 0.866 | 1/2 | √3 ≈ 1.732 |
| 90 | π/2 | 1 | 0 | undefined |
Section 2 - Translation Matrix T(tx, ty, tz)
Column-major layout (tx, ty, tz appear in column 3, GLM memory indices 12-14):
| 1 0 0 tx | | 0 1 0 ty | | 0 0 1 tz | | 0 0 0 1 |
GLM: glm::translate(mat, glm::vec3(tx, ty, tz))
Section 3 - Rotation Matrices (angle t in radians, abbreviated)
R_x(t) - rotation around X axis:
| 1 0 0 0 | | 0 cos(t) -sin(t) 0 | | 0 sin(t) cos(t) 0 | | 0 0 0 1 |
GLM: glm::rotate(mat, t, glm::vec3(1,0,0))
R_y(t) - rotation around Y axis (note sign swap: -sin at row 2, col 0):
| cos(t) 0 sin(t) 0 | | 0 1 0 0 | | -sin(t) 0 cos(t) 0 | | 0 0 0 1 |
GLM: glm::rotate(mat, t, glm::vec3(0,1,0))
R_z(t) - rotation around Z axis:
| cos(t) -sin(t) 0 0 | | sin(t) cos(t) 0 0 | | 0 0 1 0 | | 0 0 0 1 |
GLM: glm::rotate(mat, t, glm::vec3(0,0,1))
Section 4 - Perspective Projection Matrix
Parameters: f = 1/tan(fov/2), a = aspect ratio, n = near, z = far.
| f/a 0 0 0 | | 0 f 0 0 | | 0 0 -(z+n)/(z-n) -2zn/(z-n) | | 0 0 -1 0 |
M[2][3] = -1 copies -z_view into w_clip, enabling the perspective divide. After dividing clip coords by w, NDC values land in [-1, 1] for visible geometry.
GLM: glm::perspective(glm::radians(fov_degrees), aspect, near, far)
Section 5 - GLM Function Reference
| Purpose | GLM Call |
|---|---|
| Identity matrix | glm::mat4(1.0f) |
| Translation | glm::translate(mat, glm::vec3(tx, ty, tz)) |
| Rotation | glm::rotate(mat, glm::radians(degrees), axis) |
| Uniform scale | glm::scale(mat, glm::vec3(s, s, s)) |
| Perspective projection | glm::perspective(glm::radians(fov), aspect, near, far) |
| Orthographic projection | glm::ortho(left, right, bottom, top, near, far) |
| Look-at / view matrix | glm::lookAt(eye, centre, worldUp) |
| Normal matrix (C++) | glm::mat3(glm::transpose(glm::inverse(model))) |
| Normal matrix (GLSL) | mat3(transpose(inverse(model))) |