



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




This is a rudimentary cheat sheet for the lecture Computer Graphics, Winter Term 2019. It is by no means complete, rather it is optimized to fit with the challenge set by the exam. That is, it contains the formulas and matrices you are expected to recall during the exam.
a ◦ b =
a 1 a 2 a 3
b 1 b 2 b 3
(^) = a 1 b 1 + a 2 b 2 + a 3 b 3 (1)
a × b =
a 1 a 2 a 3
b 1 b 2 b 3
a 2 b 2 − a 3 b 2 a 3 b 1 − a 1 b 3 a 1 b 2 − a 2 b 1
Given two points A = (x 0 , y 0 ) and B = (x 1 , y 1 ), we want to rasterize a line from A to B. For this, we first compute updates
∆DE = 2∆y and ∆DN E = 2(∆x − ∆y) (3)
and initialize
D := ∆x − 2∆y. (4)
Then keep incrementing x := x 0 up to x 1. In each iteration, as long as x ≥ 0, we move to the east (right) and update with ∆DE. If x < 0, we move north-east (increment y) and update with ∆DN E.
3 Homogeneous Coordinates
1 w
x y z
4 Affine Transformations
Horizontal sheering keeps y fixed. On paper, it looks like the y-axis is moving. It maps the axis vector (0, 1) to (sh, 1).
1 sh 0 0 1 0 0 0 1
Vertical sheering keeps x fixed. On paper, it looks like the x-axis is moving. It maps the axis vector (1, 0) to (1, sv).
sv 1 0 0 0 1
Rotation by angle φ from origin (0, 0), anti-clockwise is implemented by
Rφ =
cos φ − sin φ 0 sin φ cos φ 0 0 0 1
In particular we get
Rπ 2 =
(^) , Rπ =
(^) , R 32 π =
6 Rotations in 3D Space
Anti-Clockwise rotation around an axis m by angle φ is achievable with matrix Rm as follows.
Rx =
0 cos φ − sin φ 0 0 sin φ cos φ 0 0 0 0 1
Ry =
cos φ 0 sin φ 0 0 1 0 0 − sin φ 0 cos φ 0 0 0 0 1
Rz =
cos φ − sin φ 0 0 sin φ cos φ 0 0 0 0 1 0 0 0 0 1
7 Camera
A camera is often defined by eye vector e, gaze direction g and view-up vector t. However, in practice it is useful to construct the (u, v, w) coordinate system for a given camera.
w = − (^) ||^1 g|| g u = (^) ||t ×^1 w|| (t × w) v = w × u (18)
8 Viewing Transformation
From camera coordinate system (u, v, w), we can construct viewing matrix
Mview =
ux uy uz −uT^ e vx vy vz −vT^ e wx wy wz −wT^ e 0 0 0 1
which moves the camera into the origin.
9 Phong Lighting Model
The Phong Lighting Model is based around three components, namely ambient light Lamb, diffuse reflection Ldif f and specular reflection Lspec.
Ambient light is constant, parameterized by two arguments.
Lamb = kamb · Iin (20)
Diffuse reflection imitates micro structure and random reflection. It is dependent on the angle φ between surface normal n and light vector l. Both n and l have to be normalized.
Ldif f = kdif f · Iin · cos φ (21) = kdif f · Iin · (n ◦ l) (22)
Specular reflection creates spotlight effects. It takes the eye position into account. To compute it, we need the perfect reflection vector r and view vector v, both of which need to be normalized. Angle ϕ is the angle between vectors v and r. Material constant m introduces a cutoff for the highlight, higher values for m result in smaller highlights.
Lspec = kspec · Iin · cosm^ ϕ (23) = kspec · Iin · (v ◦ r)m^ (24)
If perfect reflection r is not known, it can be computed in terms of
r = 2 · (n ◦ l) · n − l. (25)
10 Ray Tracing
An eye ray r is a ray starting at eye position e in direction d.
r(t) = e + t · d (26)
An intersection point x of an eye ray with some geometry is defined by distance tx the ray had to travel from eye to geometry.
x = e + tx · d (27)
Given a plane defined by a normal n and some point c on the plane, we can compute intersection point x by finding the right value for tx.
tx = (c^ −d ◦e )n^ ◦ n (28)
We only care about real solutions for tx. We also only care for solutions tx > 0 as negative values mean that we traveled in opposite of direction d.