midterm 2014

CS480 / CS680 MIDTERM – October 21, 2014
SUBMIT THIS EXAM WITH YOUR ANSWERS WRITTEN IN THE BLUE BOOK
Feel free to draw pictures to illustrate your answers.
1) (10 points) What is the essential difference between the recursion stopping criteria for the
boundary fill algorithm vs. the flood fill algorithm?
2) (10 points) How can a raster scan algorithm for circles exploit 8-fold symmetry?
3) (10 points) Consider the unit quaternion
q=(
3
1
1
,−
,0,− )
2
8
8
a. What rotation does this quaternion represent? Specifically,
i. What is the axis of rotation? (Give unit vector in direction of axis.)
€
ii. What is the angle of rotation? (If you like, use sin−1 and/ or cos−1.)
b. What is the quaternion that represents the inverse of the rotation?
4) (15 points) Usually, we think of clipping to a rectangular clipping region, but it is possible to
clip to other polygonal regions with N sides. For instance, here is window with N=8:
Before:
After:
Assume that the polygon is simple: the polygon has no self-intersections, no holes, and no
coincident vertices.
a. How would you modify the Cohen-Sutherland line-clipping algorithm to handle a
convex polygonal clipping region with N sides?
b. We apply the same algorithm to clip a line segment to a concave polygonal clipping
region and get the result shown.
Before:
After:
Why won’t the algorithm work for a concave polygonal clipping region with N
sides? Sketch an example to illustrate your answer.
5) (10 points) Assume p = ( x, y, z ,1) , pʹ′ = ( xʹ′, y ʹ′, z ʹ′, wʹ′) where
2x − z + 2
2−z
2y − 2z + 4
y' =
2−z
z' = 2
x' =
w' = 1
a. Give a homogeneous transform M such that when we homogenize Mp we get p ʹ′.
b. Is M a perspective or parallel projection matrix? Why?
6) (25 points) Our goal is to produce an image of a sphere, where the sphere appears centered in
the viewport, and the sphere fits exactly within the viewport boundary as shown below. The
sphere has center C = (15,4,15) and radius = 1.
Assume the camera’s coordinate system origin is P0 = (30,4,30). We want to view the sphere using
orthographic projection, such that the sphere appears within the window as shown.
a. Draw a diagram of the sphere and the camera coordinate systems.
b. Give the “look at” vector for an orthographic camera that would produce the image
of the sphere as shown.
c. Construct the 4x4 matrix that specifies the transformation from world coordinates to
viewing coordinates for the camera.
d. Give the orthographic projection matrix for the camera.
e. What should the window’s xmin, xmax, ymin, and ymax be?
7) (20 points) We want to determine if two 2D polygonal objects intersect. Assume that each
object is represented as a polyhedron comprising N polygons. Assume that we are given a
bounding box for each object.
a. Can the bounding boxes be used to “trivially reject” intersection of the objects? If
yes, how? If no, why?
b. Can the bounding boxes be used to “trivially accept” intersection of the objects? If
yes, how? If no, why?
c. Say that no possible trivial accept/reject test is successful for a pair of objects’
bounding boxes, and we must now test the polyhedral objects themselves for
intersection. Describe an algorithm that will test intersection of two convex 2D
polygonal objects using any algorithm(s) covered in class or in the textbook.
8) (25 points, cs680 only) Assume that we are given a simple polygon P with n vertices defined in
order, {p1, p2, … pn}. Devise two efficient algorithms:
a. Give simple polygon P, determine if the polygon is convex or concave
b. Subdivide any simple concave polygon P into a set of non-overlapping convex
polygons that exactly covers P. See the example below.