Interactive Computer Graphics - Homework 3 Solutions | CS 418, Assignments of Computer Graphics

Material Type: Assignment; Class: Interactive Computer Graphics; Subject: Computer Science; University: University of Illinois - Urbana-Champaign; Term: Unknown 1989;

Typology: Assignments

Pre 2010

Uploaded on 03/16/2009

koofers-user-6fj-1
koofers-user-6fj-1 🇺🇸

10 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 418: Homework #3 Solution
1. (20 points) You are given three RGB colors with corresponding alpha values: A= (0.7,0.5,0.6),B= (1,1,0),
and C= (0,0,1) with alpha values αA= 0.5, αB= 0.9, and αC= 0.7.
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 (Dover Eover F), or DoEoF , we need the following two components:
(DoEoF )0=αDD+ (1 αD)(E oF )0
=αDD+ (1 αD)(αEE+ (1 αE)αFF)
=αDD+ (1 αD)αEE+ (1 αD)(1 αE)αFF
α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 )0by αD oEoF to get (DoE oF ).
(a) Compute the color and alpha value for (Aover Bover C).
Solution:
(AoBoC)0= (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 (Cover Bover A).
Solution:
(CoBoA)0= (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.
2. (20 points) Consider the (uncapped) unit cone whose apex is the origin and whose radius and height are both 1.
pf3
pf4
pf5

Partial preview of the text

Download Interactive Computer Graphics - Homework 3 Solutions | CS 418 and more Assignments Computer Graphics in PDF only on Docsity!

CS 418: Homework #3 Solution

  1. (20 points) You are given three RGB colors with corresponding alpha values: A = (0. 7 , 0. 5 , 0 .6), B = (1, 1 , 0), and C = (0, 0 , 1) with alpha values αA = 0. 5 , αB = 0. 9 , and αC = 0. 7.

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.

  1. (20 points) Consider the (uncapped) unit cone whose apex is the origin and whose radius and height are both 1.

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

  1. (20 points) Suppose we want to construct a model of an ellipsoid centered at the origin, whose axes are the x, y, z coordinate axes and whose radii are a, b, c, respectively. (a) Write an implicit equation for this ellipsoid.

Solution:

F (x, y, z) = (

x a

)^2 + (

y a

)^2 + (

z a

)^2 − 1 = 0

(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.

  1. (20pts) A quadric surface is described by the implicit equation xTQx = 0 where x is the homogeneous column vector (x 1 , x 2 , x 3 , 1) and Q is a symmetric 4 × 4 matrix. Suppose you are given a ray p + td with ‖d‖ = 1. (a) Derive the equation for the value(s) of t at which the ray will intersect this surface.

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.