Course: “Computer Graphics,” ECS 175 Quarter: Fall Quarter 2020
Instructor: Bernd Hamann
WRITTEN HOMEWORK 1
• DUE DATE: THURSDAY, NOVEMBER 19, 2020
• CHEATING IS NOT ALLOWED.
Name:
ID No.:
Number of Points:
Part 1: Line drawing and clipping algorithms (25 points)
1. (6 points) Describe (words and illustration) the DDA algorithm! What is the input, what is the output,
and how does it work?
2. (4 points) Given the two pixels (i1, j1) = (1, 1) and (i2, j2) = (6, 5) (end points of a line segment), what is the sequence of pixels generated by the DDA algorithm?
3. (8 points) Describe (words and illustration) the Cohen-Sutherland line clipping algorithm for clipping a single line segment against the four edges of a 2D rectangular region! Which steps are performed when clipping the line segment with end points p1 = (−0.5, −1.0)T and p2 = (2.5, 2.0)T against the unit square [0, 1] × [0, 1]? Provide an illustration and give the end points of the line segment being drawn!
1
4. (7 points) Given the point set p1 = (−1.0, 0.5)T , p2 = (0.5, 0.5)T , p3 = (2.0, 0.5)T , p4 = (2.0, −0.5)T , p5 = (0.5, −0.5)T , p6 = (0.5, 0.25)T , p7 = (−1.0, 0.25)T , p8 = p1 = (−1.0, 0.5)T defining a closed polygon with line segments pipi+1, i = 1,…,7, give the results (illustration and coordinates) of the Sutherland- Hodgman polygon clipping algorithm when clipping this polygon against the unit square [0, 1] × [0, 1]!
2
Part 2: Transformations (50 points)
5. (8 points) Give the resulting 3 × 3 transformation matrix for transforming a 2D point (x, y, 1)T (homo- geneous coordinates) by the following sequence of transformations: i.) “translate by the 2D vector (2, 2)T ”; ii.) “rotate by −90 degrees about the origin”; and iii.) “reflect with respect to the x-axis.” Apply the resulting 3 × 3 matrix to the 2D point (2, 2, 1)T (homogeneous coordinates). What is this point’s image (in homogeneous coordinates)?
6. (7 points) Give a sequence of 2D transformations that maps the triangle with vertices v1 = (0, 0)T , v2 =(1,0)T,andv3 =(0,1)T tothetrianglewithverticesv1′ =(3,−1)T,v2′ =(1,−1)T,andv3′ =(3,0)T! Provide an illustration and give the transformation matrices in the order they must be applied to the point vi, i = 1,2,3!
7. (5 points) Consider projections from 3D space into a 2D plane. What is a parallel projection? What is an orthographic projection? What is an oblique projection? Illustrate and describe these three projections!
8. (10 points) Given the tetrahedron with vertices v1 = (0, 0, 0)T , v2 = (1, 0, 0)T , v3 = (0, 1, 0)T , and v4 = (0, 0, 1)T , give the 4 × 4 transformation matrix that performs an oblique projection onto the plane z = −2 using the 3D direction vector ⃗d = (1, 1, −1)T ! What are the x′ and y′ coordinates of the tetrahedron’s vertices after mapping vi to vi′ = (xi′, yi′, zi′)T = (xi′, yi′, −2)T in the projection plane?
3
9. (5 points) Let the 2D point p have coordinates (x, y)T with respect to the orthonormal coordinate system given by the origin o = (0, 0)T and the two basis vectors ⃗b1 = (1, 0)T and ⃗b2 = (0, 1)T . The coordinate system is rotated by +45 degrees. What are the new coordinates of the point p with respect to the new coordinate system? Provide an illustration!
4
10. (15 points) We derived a sequence of transformations for rotating a 3D point by the angle α about a (directed) axis defined by a point p0 = (x0,y0,z0)T on the axis and a normalized direction vector ⃗d =
(dx, dy, dz)T . We obtained the sequence of transformations by having the rotation axis coincide with the z-axis of the coordinate system, performing the rotation about the z-axis, and, finally, “transforming” the z-axis back to the specified rotation axis. List all transformation matrices that reduce the same problem to a rotation about the x-axis of the coordinate system! Use the abbreviations “TRANS (⃗v)” for a translation by the vector ⃗v, and “ROT (δ, axis)” for a rotation by the angle δ about a particular axis of the coordinate system. Provide an illustration!
5
Part 3: Phong lighting model and Gouraud shading (25 points)
11. (15 points total) The basic formula associated with the Phong lighting model is given by
Ip =kaIA+ IL kd(⃗l·⃗n)+ks(⃗r·⃗v)n. ||f −p||+K
The point being illuminated is p, the viewer is standing at f, and the light source with intensity IL is located at x.
a.) (9 points) Provide a simple 2D diagram that clearly defines all points and vectors that are relevant for this model.
6
b.) (3 points) Which of the parameters affect the i) ambient; ii) diffuse; and iii) specular components?
c.) (3 points) The model requires special case treatments for i) ⃗l · ⃗n ≤ 0 and ii) ⃗r · ⃗v ≤ 0. What are the proper adjustments?
12. (10 points) Given the triangle with “corner pixels” p1 = (i1, j1) = (0, 0), p2 = (i2, j2) = (4, 0), and p3 = (i3, j3) = (0, 4) with light intensity values Ip1 = 0, Ip2 = 4, and Ip3 = 4 associated with the respective “corner pixels,” what is the resulting intensity value Ip for pixel p = (i, j) = (2, 1) when performing Gouraud shading? Provide an illustration indicating the intensity values at intermediate points used in the calculation!
7