Docsity

Solved Questions - Computer Graphics | CS 3451, Study Guides, Projects, Research of Computer Graphics

Toggle sidebar
bg1
1.
(i) We need to determine intersection points of the ray starting at (0,0) and
passing through (0,1) and the intervals A and B and figure out which is
closer to (0,0). Now, intersections of that ray and the intervals are the
same as intersections of the intervals and the y-axis.
For interval B, the intersection is at (0,3) (in fact, it’s a horizontal inter-
val).
For interval A, the y-coordinate of the intersection is 2 −2∗(slope of A),
i.e. 2 −2(−98
102 ) = 400
102 >3.
Thus, the intersection of the ray and interval Bis closer to the origin and
therefore we see Bat pixel (0,1).
(ii) The pipeline approach is able to correctly resolve visibility, therefore the
answer is: B.
(iii) The screen coordinates of endpoints of Aare ( 2
2,2) = (1,2) and ( −100
100 ,100) =
(−1,100).
The screen coordinates of endpoints of Bare ( 1
3,3) and (−1
3,3).
We need the interpolated depth for fragments generated for both intervals
at x= 0, which is the point exactly in the middle of both pro jected
intervals. Thus, for Athe depth is 2+100
2= 51 and for Bthe depth is
3+3
2= 3. The interval that shows up at pixel at 0 is still B
NOTE: I meant to show that one can get a wrong answer in (iii) but somehow
it didn’t work. I guess I am not good enough with numbers. Try to figure out
the answer if the endpoints of Bare replaced with (1,4) and (1,−4), perhaps
I’ll put this variant on the final :). Be able to relate it to the depth interpolation
in graphics pipeline.
2. Assuming the viewpoint is outside the sphere, the formula (used in the ray
tracing project) is ~cp
R=p−c
R. If the point is inside, we are looking at pfrom
inside the sphere and therefore need to use unit normal pointing toward the
inside of the sphere, i.e. −~cp
R.
To sum up, the pseudocode could be:
if |c−v|< R then return −~cp
Relse return ~cp
R
Another way to look at it (cf our treatment of triangle’s normal in class)
would be to make sure that the normal vector points to the side of the tangent
plane at pthat contains the viewpoint. This leads to the following pseudocode:
if ~pc ·~pv ≥0then return −~cp
Relse return ~cp
R
Of course, there are several equivalent ways to write any of the above.
3. Notice that from (a) we immediately get a13 = 3 and a23 = 4 (since the point
(0,0) gets mapped into (a13, a23 ) – just do matrix-vector multiplication).
1
pf3

Partial preview of the text

Download Solved Questions - Computer Graphics | CS 3451 and more Study Guides, Projects, Research Computer Graphics in PDF only on Docsity!

(i) We need to determine intersection points of the ray starting at (0, 0) and passing through (0, 1) and the intervals A and B and figure out which is closer to (0, 0). Now, intersections of that ray and the intervals are the same as intersections of the intervals and the y-axis. For interval B, the intersection is at (0, 3) (in fact, it’s a horizontal inter- val). For interval A, the y-coordinate of the intersection is 2 − 2 ∗(slope of A), i.e. 2 − 2(− 10298 ) = 400102 > 3. Thus, the intersection of the ray and interval B is closer to the origin and therefore we see B at pixel (0, 1).

(ii) The pipeline approach is able to correctly resolve visibility, therefore the answer is: B.

(iii) The screen coordinates of endpoints of A are ( 22 , 2) = (1, 2) and ( − 100100 , 100) = (− 1 , 100). The screen coordinates of endpoints of B are ( 13 , 3) and (− 13 , 3). We need the interpolated depth for fragments generated for both intervals at x = 0, which is the point exactly in the middle of both projected intervals. Thus, for A the depth is 2+100 2 = 51 and for B the depth is 3+ 2 = 3. The interval that shows up at pixel at 0 is still^ B NOTE: I meant to show that one can get a wrong answer in (iii) but somehow it didn’t work. I guess I am not good enough with numbers. Try to figure out the answer if the endpoints of B are replaced with (1, 4) and (1, −4), perhaps I’ll put this variant on the final :). Be able to relate it to the depth interpolation in graphics pipeline.

  1. Assuming the viewpoint is outside the sphere, the formula (used in the ray tracing project) is cp~R = p−Rc. If the point is inside, we are looking at p from inside the sphere and therefore need to use unit normal pointing toward the inside of the sphere, i.e. − cpR~. To sum up, the pseudocode could be: if |c − v| < R then return − cpR~ else return cpR~

Another way to look at it (cf our treatment of triangle’s normal in class) would be to make sure that the normal vector points to the side of the tangent plane at p that contains the viewpoint. This leads to the following pseudocode: if pc~ · pv~ ≥ 0 then return − cpR~ else return cpR~ Of course, there are several equivalent ways to write any of the above.

  1. Notice that from (a) we immediately get a 13 = 3 and a 23 = 4 (since the point (0, 0) gets mapped into (a 13 , a 23 ) – just do matrix-vector multiplication).

Now, (b) gives equations

a 11 + 2a 12 + 3 = 7 a 21 + 2a 22 + 4 = 9

and (c)

−a 11 + a 12 + 3 = 3 −a 21 + a 22 + 4 = 5

All of the above are obtained by multiplying the unknown (except for last col- umn) matrix by vectors representing points (1, 2) and (− 1 , 1) in homogenous coordinates. These are four equations with four unknowns. In fact, we have two pairs of equations with two unknowns each. a 11 and a 12 can be computed from the first and third equation: a 11 = 4/3 and a 12 = 4/3. Similarly, a 21 and a 22 can be computed from the second and fourth equation. a 22 = 2 and a 21 = 1. Answer: (^) 

  1. The easiest way to solve this one is to draw a picture. The intersections of the triangle’s edges and the edges of the viewport are at (− 58 , −1) and (− 1 , − 58 ). Apart from them, we have three more vertices of the clipped triangle: (− 1 , −1), (− 0. 5 , 0) and (0, − 0 .5). Answer: (− 1 , −1), (− 58 , −1), (0, − 0 .5), (− 0. 5 , 0), (− 1 , − 58 ).
  2. The approach that appeared in class in a close form is to embed the triangle in 3D by adding zero z-coordinate to all vertices. As a result of the embedding, we have a 3D triangle with vertices a = (x 1 , y 1 , 0), b = (x 2 , y 2 , 0) and c = (x 3 , y 3 , 0). The cross product ab~ × ac~ will point in the direction of the z axis or in the opposite direction, depending on whether vertices come in clockwise o counterclockwise order (this is because the 3D vertices appear in consistent order when looked at from the direction of the cross product). The z-coordinate of the cross product is the determinant of [ x 2 − x 1 y 2 − y 1 x 3 − x 1 y 3 − y 1

]

or (x 2 − x 1 )(y 3 − y 1 ) − (y 2 − y 1 )(x 3 − x 1 ). The algebraic condition would be true if vertices come in counterclockwise order is

(x 2 − x 1 )(y 3 − y 1 ) − (y 2 − y 1 )(x 3 − x 1 ) ≥ 0