



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Interactive Computer Graphics; Subject: Computer Science; University: University of Illinois - Urbana-Champaign; Term: Unknown 1989;
Typology: Assignments
1 / 5
This page cannot be seen from the preview
Don't miss anything!




Solution:
For both parts below it will be useful to derive a general formula for calculating the composition of 3 colors, which we denote D, E and F. To compute (D over E over F ), or DoEoF , we need the following two components:
(DoEoF )′^ = αD D + (1 − αD )(EoF )′ = αD D + (1 − αD )(αE E + (1 − αE )αF F ) = αD D + (1 − αD )αE E + (1 − αD )(1 − αE )αF F αDoEoF = αD + (1 − αD )(αEoF ) = αD + (1 − αD )(αE + (1 − αE )αF ) = αD + (1 − αD )αE + (1 − αD )(1 − αE )αF
Then we de-multiply (DoEoF )′^ by αDoEoF to get (DoEoF ).
(a) Compute the color and alpha value for (A over B over C).
Solution:
(AoBoC)′^ = (0. 8 , 0. 7 , 0 .335) αAoBoC =. 985 De-multiply, we get: AoBoC = (0. 812 , 0. 711 , 0 .340)
(b) Compute the color and alpha value for (C over B over A).
Solution:
(CoBoA)′^ = (0. 281 , 0. 278 , 0 .709) αCoBoA =. 985 De-multiply, we get: CoBoA = (0. 285 , 0. 282 , 0 .720) We can see that in general, AoBoC is not the same as CoBoA.
y
z
radius r = 1
height h = 1
x
(a) What is the parametric form of this surface? Make sure to indicate what your parameter values mean and what their ranges are.
Solution:
x = r cos θ y = r z = r sin θ with 0 ≤ θ < 2 π, 0 ≤ r ≤ 1.
(b) Briefly describe how to generate this object as a generalized cylinder.
Solution:
To define a generalized cylinder, we need to specify its cross section and scaling function. For this cone example, using 0 ≤ r ≤ 1 as the parameter, the cross section is circle x^2 + z^2 = r^2 , and scaling function is s(r) = r.
(c) What is the implicit form of this cone? You can assume that the coordinates will always be restricted to the range 0 ≤ x, y, z ≤ 1.
Solution: x^2 + z^2 − y^2 = 0
Solution:
F (x, y, z) = (
x a
y a
z a
(b) Convert this equation into the standard quadratic form vTQv = 0.
Solution:
We have squared terms for x, y, z, and a constant. When put into a matrix Q, they fir in the diagonals so we get the correct terms when multiplied with vT^ and v.
t = (n · p + d)/(n · n) = (n · p + d)
After finding t, we plug it back into the ray equation: q = p − (n · p + d)n.
(b) Derive the equation for the location of the point p projected onto the plane through the origin (0, 0 , 0) as pictured in the figure below.
Solution:
Let q be this location. Then q = t (^) ‖pp‖ since we are projecting from the origin through p. Again, plug into the plane equation to solve for t: n · (t (^) ‖pp‖ ) + d = 0 t( (^) ‖pp·n‖ ) = −d t = ( − pd‖·np ‖)
Put t back into the ray equation: q = ( (^) (−pd·n‖p)‖‖pp‖ ) = −pd·np
(c) Suppose that we now want to write some code to do projective shadows as discussed in class. Using the equation you derived in the previous part, detail how you would support projection onto a plane through any arbitrary point (not just the origin).
Solution: Given an arbitrary point r, we would first translate the plane and point p by −r so that we are projecting from the origin. Use the above equation to find the projection point, then translate the resulting point by r to obtain the final answer. Alternatively, we can obtain an exact equation if we take into account projecting from an arbitrary point r. Then q = r + t (^) ‖pp−−rr‖ for some t, since we are casting a ray from the point r through point p.
Plug into plane equation to solve for t: n · (r + t (^) ‖pp−−rr‖ ) + d = 0 t( ( ‖pp−−r)r·‖n ) = −d − n · r t = (−d− (pn−·rr))‖·pn−r‖
Put t back into the ray equation: q = r + ( (−d− (pn−·rr))‖·pn− r‖) (^) ‖pp−−rr‖ = r + (−d− nn·r)
Full credit is given for both approaches.
Solution:
We can substitute x in the implicit equation with the equation of the ray: (p + td)T^ Q(p + td) = 0 Using the rule xT^ Qx = x · Qx, we can eliminate the transpose: (p + td) · Q(p + td) = 0 Multiply into terms of t: p · Q(p + td) + (td) · Q(p + td) = 0 p · Qp + p · tQd + (td) · Qp + (td) · tQd = 0
(d · Qd)t^2 + (p · Qd + d · tQp)t + p · Qp = 0
Since Q is symmetric, x · Qy = y · Qx (Or if you chose not to eliminate transposes, xT^ Qy = yT^ Qx). However, note that x · Qy 6 = (x · y)x. We then simplify to: (d · Qd)t^2 + 2(p · Qd)t + p · Qp = 0
This is in a quadratic form, where a = d · Qd, b = 2(p · Qd), c = p · Qp, and t = −b±
√ b^2 − 4 ac 2 a.
(b) A given ray may intersect a quadric at 0, 1, or 2 spots. Derive an expression which can be used to test whether the ray intersects the surface or whether it misses it entirely.
Solution: If the discriminant, b^2 − 4 ac, equals 0, and the resulting t ≥ 0 , the ray hits in one spot. If the discriminant is greater than 0, there is a hit for every positive t (up to two hits). Otherwise the ray misses.