Practice Midterm Solution for Computer Graphics | CMSC 427, Exams of Computer Graphics

Material Type: Exam; Professor: Jacobs; Class: Computer Graphics; Subject: Computer Science; University: University of Maryland; Term: Unknown 1989;

Typology: Exams

Pre 2010

Uploaded on 02/13/2009

koofers-user-9en
koofers-user-9en ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Practice Midterm Solutions
CMSC 427
Sample Problems (Note, some of these problems may be a bit more involved than ones
Iโ€™d ask on a time-limited exam).
1. Create a matrix that rotates points 90 degrees about the point (1,1).
We can do this by translating to the origin, rotating, and translating back. We get:
๎˜
๎˜
๎˜
๎˜‚
๎˜ƒ
๎˜„
๎˜„
๎˜„
๎˜…
๎˜†โˆ’
=
๎˜
๎˜
๎˜
๎˜‚
๎˜ƒ
๎˜„
๎˜„
๎˜„
๎˜…
๎˜†
โˆ’
โˆ’
๎˜
๎˜
๎˜
๎˜‚
๎˜ƒ
๎˜„
๎˜„
๎˜„
๎˜…
๎˜†
=
๎˜
๎˜
๎˜
๎˜‚
๎˜ƒ
๎˜„
๎˜„
๎˜„
๎˜…
๎˜†
โˆ’
โˆ’
๎˜
๎˜
๎˜
๎˜‚
๎˜ƒ
๎˜„
๎˜„
๎˜„
๎˜…
๎˜†โˆ’
๎˜
๎˜
๎˜
๎˜‚
๎˜ƒ
๎˜„
๎˜„
๎˜„
๎˜…
๎˜†
100
001
210
100
101
110
100
110
101
100
110
101
100
001
010
100
110
101
We can verify that this is right by checking that it takes the point (1,1) (written (1,1,1) in
homogenous coordinates) to the point (1,1), and that it takes the point (2,1) to (1,2).
2. What is the distance from (3,2) to (7,5) in the direction (1,2)?
To do this we need to find the inner product between a vector from (3,2) to (7,5) and a
unit vector in the direction (1,2). The first vector is (4,3). The unit vector we need is
(1,2)/sqrt(5). This inner product is 10/sqrt(5)=2sqrt(5)
3. Provide any two rows of a 4x4 matrix that will transform 3D points as they would
appear in the coordinate system of a viewer centered at (3,2,0) facing in the
direction (1,2,3). The new z coordinate should describe the distance from the
viewer to a point, in the direction that they are viewing it.
We are changing the origin and the viewing direction. We can do this by combining two
matrices. If we just wanted to change origins, all we would need to do is create a 3D
translation matrix that takes (3,2,0) to the origin. This would be:
๎˜
๎˜
๎˜
๎˜
๎˜
๎˜‚
๎˜ƒ
๎˜„
๎˜„
๎˜„
๎˜„
๎˜„
๎˜…
๎˜†
โˆ’
โˆ’
1000
0100
2010
3001
However, we also want to change the viewing direction. To do this, weโ€™ll create a matrix
in which the first three elements of the third row represent our new z direction. This
direction is represented by the unit vector (1,2,3)/sqrt(14). So, the matrix we want will
look like:
pf3
pf4

Partial preview of the text

Download Practice Midterm Solution for Computer Graphics | CMSC 427 and more Exams Computer Graphics in PDF only on Docsity!

Practice Midterm Solutions CMSC 427

Sample Problems (Note, some of these problems may be a bit more involved than ones Iโ€™d ask on a time-limited exam).

  1. Create a matrix that rotates points 90 degrees about the point (1,1).

We can do this by translating to the origin, rotating, and translating back. We get:

We can verify that this is right by checking that it takes the point (1,1) (written (1,1,1) in homogenous coordinates) to the point (1,1), and that it takes the point (2,1) to (1,2).

  1. What is the distance from (3,2) to (7,5) in the direction (1,2)?

To do this we need to find the inner product between a vector from (3,2) to (7,5) and a unit vector in the direction (1,2). The first vector is (4,3). The unit vector we need is (1,2)/sqrt(5). This inner product is 10/sqrt(5)=2sqrt(5)

  1. Provide any two rows of a 4x4 matrix that will transform 3D points as they would appear in the coordinate system of a viewer centered at (3,2,0) facing in the direction (1,2,3). The new z coordinate should describe the distance from the viewer to a point, in the direction that they are viewing it.

We are changing the origin and the viewing direction. We can do this by combining two matrices. If we just wanted to change origins, all we would need to do is create a 3D translation matrix that takes (3,2,0) to the origin. This would be:

However, we also want to change the viewing direction. To do this, weโ€™ll create a matrix in which the first three elements of the third row represent our new z direction. This direction is represented by the unit vector (1,2,3)/sqrt(14). So, the matrix we want will look like:

Notice that to get the bottom two rows we never had to come up with the top two rows of the first matrix on the left.

  1. Suppose you have a camera with a focal point at (0,0,0) and an image plane of z=1. Give an example of a right triangle in 3D that will also appear in the image as a right triangle, assuming perspective projection. Do the same thing for orthographic projection.

Perspective projection scales points by the inverse of their distance. So, if we pick points that have the same z coordinate, they will all be scaled the same amount. So, for example, if we take a triangle with vertices at (0,0,2) (2,0,2), (0, 2, 2), this will appear in images with coordinates (0,0), (1,0), (0,1), and still be a right triangle.

With orthographic projection, the same triangle will appear as (0,0), (2,0), (0,2), also a right triangle.

  1. Prove that parallel lines in the world do not always appear as parallel lines with perspective projection.

We just need an example to show this. Letโ€™s consider lines that lie in the y=-5 plane, with our standard perspective camera. Consider a line with the equation z = mx+b. This contains the points (0,-5,b) and (1,-5, m+b). These appear in the image as points (0, -5/b) and (1/(m+b), -5/(m+b)). This line has a slope of (-5/(m+b) + 5/b)/(1/(m+b)) = -5 + 5(m+b)/b = 5m/b. Clearly this slope depends not just on m, the slope of the original line, but also on b. Two lines with the same value for m and different values for b will be parallel in the world, but will have different slopes in the image.

  1. Explain how you would adapt DDA to discretely represent the boundary of a circle. What pixels would be filled in to represent a circle centered at (20,20) with a radius of 5?

First, letโ€™s consider the simpler, naรฏve algorithm. We cannot just increment x from 15 to 25, and solve for two y values for each x, because in some parts of the circle y changes more rapidly than x, so we would get a circle with gaps. Instead, we can divide the circle into regions where either x or y is changing more rapidly. For example, at an angle between pi/4 and 0, y is changing more rapidly. This occurs in the region of the circle starting at (20+5/sqrt(2), 20+5/sqrt(2)) and ending at (25,20). Rounding off, this means we must consider y values of 24, 23, 22, 21, 20. For these, the corresponding x values are 23, 24, 25,25,25, so we fill in points (23,24), (24,23), (25,22), (25,21), (25,20).

Sampling this produces (1 1 ยผ 0 ยผ 1 1 ยผ 0 ยผ โ€ฆ.). Now the average intensity in the image is still .5 (can you prove that this will always be true) and we have something that looks more like equal sized white and black stripes.

  1. Suppose we apply the Efros and Leung texture synthesis algorithm to an image consisting of vertical black and white stripes. What do you think we might get? How might this depend on the parameters that we use?

The key issue here is how big a neighborhood we use when deciding whether things are similar. If we use a neighborhood, that is big enough to capture a full stripe, then we will reproduce stripes of equal length. If we use a smaller neighborhood, weโ€™ll still get black and white stripes, but they may not be of equal length.

  1. If a pixel has RGB values of (.7, .3, .2), how would you describe its HSV values?

v will be the value of the largest component. So v = .7.

White light with the same value would be (.7, .7, .7). We can make light that is completely saturated, but has the same hue as our light by subtracting out the white, which would produce (.5, .1, 0). If we scale this light by 1.4 we get saturated light of the same hue, but with a value of .7, that is represented in RGB as (.7, .14, 0). Our light is therefore part way in between the fully unsaturated gray light (.7,.7,.7) and the saturated light at (.7, .14, 0). What fraction of the way are we from fully unsaturated to saturated? .4/.56, or .5/.7, both of which equal 5/7. Hue is represented by the angle between our light and red. For example, we can use (.7,.7,.7) as the origin, and find the angle between (.7,0,0) and (.7,.14,0). Things look a little simpler if we scale everything by 1/.7, in which case the origin is (1,1,1), red is at (1,0,0), and our hue is at (1, .2,0). This is about 6 degrees.

If a pixel has a hue of green, a saturation of .5, and a value of .4, describe it with RGB values.

Gray with a value of .4 would be (.4,.4,.4). Green with this value would be (0, .4, 0). Our color is halfway in between these two, so itโ€™s (.2, .4, .2).

  1. Suppose you had a monitor that emitted light that was either cyan, magenta or yellow. How could you use this to create white light?

Representing these in rgb, they are (0 1 1), (1 0 1) (1 1 0). These are usually used in a subtractive system, where mixing them together will produce black. But in a monitor, small colored lights are added together, and so we will have equal parts of red, green and blue, which will appear white.