CS 418: Homework Solution - Cubic Splines and Shape Transformations, Assignments of Computer Graphics

Solutions to various problems related to cubic splines and shape transformations. The first problem involves deriving the basis matrix for a new spline type with given control points and tangents. The second problem deals with transforming an initial shape into given figures using combinations of translate, scale, and rotate transformations. The third problem explains why a specular highlight appears when rendering a cylinder using phong shading instead of gouraud shading. The fourth problem involves calculating the composition of three polygons using given rgb colors and alpha values.

Typology: Assignments

Pre 2010

Uploaded on 03/16/2009

koofers-user-fbn-1
koofers-user-fbn-1 🇺🇸

9 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 418: Homework #2
Solution
1. We want to define a new spline type with control points p0,p3,r1,r2. The curve should interpolate its
endpoints p0,p3and should have tangents r1,r2at u=1
/
2and u=3
/
4, respectively. Given that our
standard matrix-form for this cubic splines will be
p(u) = 1u u2u3M
p0
p3
r1
r2
derive the 4×4 basis matrix Mfor this class of splines.
Solution:
Suppose
p(u) = a0+a1u+a2u2+a3u3=1u u2u3
a0
a1
a2
a3
then
a0
a1
a2
a3
=M
p0
p3
r1
r2
()
The four equations defining pcan be written as:
p(0) = p0=a0
p(1) = p2=a0+a1+a2+a3
p0(1
2) = r1=a1+a2+3
4a3
p0(3
4) = r2=a1+3
2a2+27
16a3
Write these equations in matrix form, we get:
p0
p3
r1
r2
=
1 0 0 0
1 1 1 1
0 1 1 3
4
0 1 3
2
27
16
a0
a1
a2
a3
thus
a0
a1
a2
a3
=
1 0 0 0
1 1 1 1
0 1 1 3
4
0 1 3
2
27
16
1
p0
p3
r1
r2
;
Compare this with (*) we get:
M=
1 0 0 0
1 1 1 1
0 1 1 3
4
0 1 3
2
27
16
1
pf3
pf4
pf5

Partial preview of the text

Download CS 418: Homework Solution - Cubic Splines and Shape Transformations and more Assignments Computer Graphics in PDF only on Docsity!

CS 418: Homework

Solution

  1. We want to define a new spline type with control points p 0 , p 3 , r 1 , r 2. The curve should interpolate its

endpoints p 0 , p 3 and should have tangents r 1 , r 2 at u = 1 / 2 and u = 3 / 4 , respectively. Given that our

standard matrix-form for this cubic splines will be

p(u) =

[

1 u u

2 u

3

]

M

p 0

p 3

r 1

r 2

derive the 4×4 basis matrix M for this class of splines.

Solution:

Suppose

p(u) = a 0 + a 1 u + a 2 u

2

  • a 3 u

3

[

1 u u

2 u

3

]

a 0

a 1

a 2

a 3

then

a 0

a 1

a 2

a 3

 =^ M

p 0

p 3

r 1

r 2

The four equations defining p can be written as:

p(0) = p 0 = a 0

p(1) = p 2 = a 0 + a 1 + a 2 + a 3

p

′ (

) = r 1 = a 1 + a 2 +

a 3

p

′ (

) = r 2 = a 1 +

a 2 +

a 3

Write these equations in matrix form, we get:

p 0

p 3

r 1

r 2

3 4 0 1

3 2

27 16

a 0

a 1

a 2

a 3

thus 

a 0

a 1

a 2

a 3

3 4 0 1

3 2

27 16

p 0

p 3

r 1

r 2

Compare this with (*) we get:

M =

3 4 0 1

3 2

27 16

− 1

NOTE: It is acceptable to leave answer as a matrix to be inverted as above.

M =

9 2

9 2

3 2

15 2

15 2

11 2

  1. Suppose that you are given the following shape:

(−1, −1)

(1, 1)

For each of the following figures, describe how to transform the initial shape above into the given result.

You may only use combinations of the following three transformations:

T : translate by [1 1] S : scale by [2 1] R : rotate (counter-clockwise) by 45

NOTE: Your answers should consist of products of these 3 fundamental matrices. Make sure to put

them in the correct order.

(a) (b) (c) (d)

(a) Solution:

T

(b) Solution:

RS

(c) Solution:

RRRRT = R

4 T

For both parts below it will be useful to derive a general formula for calculating the composition of 3

polygons.

Lets find a formula for (D over E over F ) and its corresponding alpha value.

αD D + (1 − αD )(E over F )

αD D + (1 − αD )(αE E + (1 − αE )αF F )

αD D + (1 − αD )αE E + (1 − αD )(1 − αE )αF F

Let the alpha value of (D over E over F ) be αDoEoF. αDoEoF will be used to de-premultiply the result

of the equation above.

αDoEoF = αD + (1 − αD )(αEoF )

αDoEoF = αD + (1 − αD )(αE + (1 − αE )αF )

αDoEoF = αD + (1 − αD )αE + (1 − αD )(1 − αE )αF

(a) Calculate (A over B over C) using the composition rules defined in class.

Solution:

(A over B over C)

′ = (0. 8 , 0. 7 , 0 .335)

De-premultiply:

αAoBoC =. 985

A over B over C = (0. 812 , 0. 711 , 0 .340)

(b) Calculate (C over B over A) using the composition rules defined in class.

Solution:

(C over B over A)

′ = (0. 281 , 0. 278 , 0 .709)

De-premultiply:

αCoBoA =. 985

C over B over A = (0. 285 , 0. 282 , 0 .720)

  1. Consider a plane described by the equation n·p + d = 0. Suppose that we wish to shade this plane using

the Phong illumination equation discussed in class. Assume that the reflectance coefficients kd, ks, ka are

given to you. Furthermore, assume that the single point light source in the scene is located at position

x and emits light with intensity IL. The camera is located at position e.

(a) Consider some point p on the plane. Compute the intensity of diffuse reflectance at this point p.

Solution:

ID = ILkd max(n·

(x − p)

‖x − p‖

(b) The point on the plane for which the diffuse reflectance is maximal is the perpendicular projection

of x onto the plane. Explain why this is true.

Solution:

The diffuse reflectance is maximal when n·

(x−p) ‖x−p‖ is maximal. The dot product is maximized when

the angle beween two vectors is 0. In the context of this problem, this means that n ·

(x−p) ‖x−p‖ is

maximized when n and

(x−p) ‖x−p‖

are the same vector (i.e. when the light vector and normal vector

are the same, which is the perpendicular projection of x onto the plane).

(c) Derive an equation for the perpendicular projection of x onto the plane.

Solution:

Let p be a point on the plane.

Let w be the vector from p to x.

Let q be the perpendicular projection of x onto the plane.

w = x − p

q = x − (signed projection of w onto n)n

q = x − (w·n)n

q = x − ((x − p)·n)n