Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Untitled

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

IE500217 – Computer Graphics I

Assignment 03
Name: Xiangming Shen

1. Write an implicit equation for the 2D line through points (x0, y0) and (x1, y1) using a 2D
determinant.
Answer:
the determinant could be expressed as:
x − x0 y − y0
=0
x1 − x0 y1 − y0

2. Show that for three 3D vectors a, b, and c, the following identity holds: |a, b, c| = (a × b) · c
Answer:
The signed volumn a parallelepipaed formed by Vectors (a,b,c) can be denoted by the terminant |
a,b,c|.
On the other side, the a × b = ||a|| ||b|| sin(phi) is the signed area S of the parallelogram formed by
the vector (a,b), and with direction that is perpendicular to the plane, denoted as n, and n · c is the
projection of c onto n, and equals height of the parallelepipaed. So (a × b) · c equals to the volumn
too.

3. Given the (x, y) coordinates of the three vertices of a 2D triangle, explain why the area is given
by

Answer:
Similar to Question 2, the three vectors are a = (x0,y0,1), b = (x1, y1, 1), c = (x2, y2, 1), which is
three points on the plane of z = 1.
The dominant |abc| is the volumn of the parallelepipaed formed by the three vectors, whose bottom
is a parralelogram of (x0, y0), (x1, y1), and (x2, y2), and with height =1.
Thus the area equals the volumn, and since it’s a parallelogram, its area is two times of the
triangle. Thus the area of the triangle is 1/2*|abc|.

4. Invert A and show that AA−1 = I.

Answer:
2 3 4
2 1 1 1 1 2
1 2 1 =2 −3 +4 = 2 *8 − 6 + 4 *(−4) = −6
6 7 5 7 5 6
5 6 7
⎡ ⎤
⎢ 2 1 3 4 3 4 ⎥

−1
⎢ 6 7 6 7 2 1 ⎥
⎡ 2 3 4 ⎤ ⎢ ⎥ ⎡ 8 3 −5 ⎤
⎢ ⎥ = 1 ⎢ − 1 1 2 4

2 4 ⎥ 1 ⎢ ⎥
⎢ 1 2 1 ⎥ −6 ⎢ ⎥= −6 ⎢ −2 −6 2 ⎥
⎢ 5 7 5 7 1 1 ⎥
⎢⎣ 5 6 7 ⎥⎦ ⎢⎣ −4 3 1 ⎥⎦
⎢ ⎥
⎢ 1 2 2 3 2 3 ⎥

⎢ 5 6 5 6 1 2 ⎥
⎣ ⎦
⎡ 2 3 4 ⎤ ⎡ 8 3 −5 ⎤
−1 ⎢ ⎥ 1 ⎢ ⎥
A⋅ A = ⎢ 1 2 1 ⎥ ⋅ ⎢ −2 −6 2 ⎥
−6
⎢⎣ 5 6 7 ⎥⎦ ⎢⎣ −4 3 1 ⎥⎦
⎡ 2 *8 + 3*(−2) + 4 * −4 0 0 ⎤
1 ⎢ ⎥
= ⎢ 0 −6 0 ⎥
−6
⎢ 0 0 −6 ⎥⎦

⎡ −6 0 0 ⎤ ⎡ 1 0 0 ⎤
1 ⎢ ⎥ ⎢ ⎥
= 0 −6 0 ⎥ = ⎢ 0 1 0 ⎥ = I
−6 ⎢
⎢⎣ 0 0 −6 ⎥⎦ ⎢⎣ 0 0 1 ⎥⎦
5. Solve the following equations using matrices.

Answer:
⎡ 2 1 −1 ⎤ ⎡ x ⎤ ⎡ 10 ⎤
⎢ ⎥ ⎢ y ⎥ = ⎢ 13 ⎥
⎢ −1 −1 1 ⎥⎢ ⎥ ⎢ ⎥
⎢ ⎥
⎢⎣ −1 2 1 ⎥⎦ ⎣ z ⎦ ⎣ ⎢ 28 ⎥⎦

2 1 −1
A = −1 −1 1 = −3
−1 2 1

10 1 −1 2 10 −1 2 1 10
13 −1 1 −1 13 1 −1 −1 13
28 2 1 −1 28 1 −1 2 28
x= = 23 , y = = 5, z = = 41
A A A

6. Consider the following matrices representing transformations on 3D points in homogeneous


coordinates.

(a) Describe the transformation of each one of the matrices above (e.g., X represents a rotation by
Y degrees, etc.), using the categories: scale, translation, rotation, projection.
Answer:
A is scaling (Shrink) y by 0.5;
B is translate by vector (3,2,1) , and the 2 is perspective viewing, indicating of 1/2 for all
coordinates.
Or to say, this matrix is a combination of scaling with translating, scaling is 1/2, and translating is
(3,2,1).
C is projection to xz plane
D is rotation around y axis with angle of 330 deg

(b) What matrix would you use to rotate 30deg clockwise around the y-axis.
Answer:
To use Matrix D, anti-clockwise 330 degree is the same to clockwise 30 deg.

(c) Suppose you wanted to undo the effect of BA. Write a single matrix that can achieve such a
result.
Answer:
⎡ 1 3 ⎤ ⎡ 1 0 ⎤ ⎡ 1 −3 / 2 ⎤
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
2 2 ⎥⋅⎢ 0.5 0 ⎥)−1 = ⎢ 2 −2 ⎥
(BA)−1 = ( ⎢
⎢ 1 1 ⎥ ⎢ 1 0 ⎥ ⎢ 1 −1/ 2 ⎥
⎢ 2 ⎥ ⎢ ⎥ ⎢ ⎥
⎣ ⎦ ⎣ 1 ⎦ ⎣ 1/ 2 ⎦

(d) Is it possible to write a matrix to undo C? (explain, in your own words, why that is the case)
Answer:
Since any y axis info will be projected to 0, thus inverse can be any, thus not possible to undo. Or
put it another way, the C matrix has a row/volomn of zeroes, thus its determinant is zero, which
can’t be divided, thus it has no inverse.

7. In the following questions, you are required to express all the transformations by 3 × 3
homogeneous transformation matrices.
(a) Supposing that the characters “8” and “∞” are both symmetric in the particular font (Fig. 1),
there are four different transformations that can transform from Fig. 1(a) to Fig. 1(b). Compute
these transformations.

Answer:
M1 = tranlate([0.5,0.5])rotate(90°)tranlate([−0.5,−0.5])
⎡ 1 0.5 ⎤ ⎡ 0 −1 ⎤⎡ 1 −0.5 ⎤ ⎡ −1 1 ⎤
⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥
=⎢ 1 0.5 ⎥ ⎢ 1 0 ⎥⎢ 1 −0.5 ⎥ = ⎢ 1 0 ⎥
⎢⎣ 1 ⎥⎦ ⎢⎣ 1 ⎥⎦ ⎢⎣ 1 ⎥⎦ ⎢⎣ 1 ⎥⎦
M 2 = tranlate([0.5,0.5])rotate(−90°)tranlate([−0.5,−0.5])
⎡ 1 0.5 ⎤ ⎡ 0 1 ⎤⎡ 1 −0.5 ⎤ ⎡ 1 ⎤
⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥
=⎢ 1 0.5 ⎥ ⎢ −1 0 ⎥⎢ 1 −0.5 ⎥ = ⎢ −1 0 1 ⎥
⎢⎣ 1 ⎥⎦ ⎢⎣ 1 ⎥⎦ ⎢⎣ 1 ⎥⎦ ⎢⎣ 1 ⎥⎦
M 3 = tranlate([1,0])rotate(90°)
⎡ 1 1 ⎤ ⎡ 0 −1 ⎤ ⎡ −1 1 ⎤

=⎢ ⎥ ⎢ ⎥ ⎢ ⎥
1 ⎥⎢ 1 0 ⎥=⎢ 1 0 ⎥
⎢⎣ 1 ⎥⎦ ⎢⎣ 1 ⎥⎦ ⎢⎣ 1 ⎥⎦
M 4 = tranlate([0,1])rotate(−90°)
⎡ 1 ⎤⎡ 0 1 ⎤ ⎡ 1 0 ⎤

=⎢ ⎥ ⎢ ⎥ ⎢ ⎥
1 1 ⎥ ⎢ −1 0 ⎥ = ⎢ −1 0 1 ⎥
⎢⎣ 1 ⎥⎦ ⎢⎣ 1 ⎥⎦ ⎢⎣ 1 ⎥⎦

(b) Among the four transformations, only one can transform from Fig. 2(a) to Fig. 2(b). Point out
which one.

Answer:
M3 can do it. since this shape might not be symmetric, thus tranlating to origin (0,0) might be not
the centre of it.

(c) Choosing different origins will change the transformation matrix. Compute the transformation
matrix for Fig. 2, if we place the new origin at the point (0.8, 0).
Answer:
M 1′ = tranlate([0.2,0])rotate(90°)tranlate([0.8,0])
⎡ 1 0.2 ⎤ ⎡ 0 −1 ⎤⎡ 1 0.8 ⎤ ⎡ −1 0.2 ⎤
⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥
=⎢ 1 0 ⎥⎢ 1 0 ⎥⎢ 1 0 ⎥ = ⎢ 1 0 0.8 ⎥
⎢⎣ 1 ⎥⎦ ⎢⎣ 1 ⎥⎦ ⎢⎣ 1 ⎥⎦ ⎢⎣ 1 ⎥⎦

8. Describe different applications of homogeneous coordinates in Computer Graphics.


Answer:
(1) Homogeneous coordinates are used nearly universally to represent transformations in graphics
systems, such as affine transformation, tranlation, rotation, etc. And thus they underlie the
design and operation of renderers implemented in graphics hardware.
(2) Homogeneous coordinates [x,y,z,w] can also be useful to draw scenes in perspective, when the
homogeneous coordinate w takes value other than one or zero, it can present point (x/w,y/w,z/
w), allowing broader range of transformations to be implemented. A transformation like this is
known as a projective transformation or a homography.

9. Address the following questions:


(a) Find the homogeneous matrix R that describes a rotation of 135 degrees around the z axis.
Answer:
⎡ 1 1 ⎤
− −
⎡ cos(135°) − sin(135°) ⎤ ⎢⎢ 2 2


⎢ ⎥ ⎢ ⎥
R=⎢ ⎥=⎢ 1
sin(135°) cos(135°) 1
⎢ ⎥ ⎢ − ⎥
⎢ 1 ⎥ ⎢ 2 2 ⎥
⎢⎣ 1 ⎥⎦ ⎥
⎢ 1 ⎥
⎢⎣ 1 ⎥⎦

(b) Find the homogeneous matrix T that describes a translation by the vector (1, 2, 3).
Answer:
⎡ 1 1 ⎤
⎢ ⎥
⎢ 1 2 ⎥
T=
⎢ 1 3 ⎥
⎢ 1 ⎥⎦

(c) Compute the matrix TR. Explain your result.


Answer:
⎡ 1 1 ⎤ ⎡ 1 1 ⎤
⎢ − − ⎥ ⎢ − − 1 ⎥
⎡ 1 1 ⎤ ⎢ 2 2 ⎥ ⎢ 2 2 ⎥
⎢ ⎥ ⎢ ⎥ ⎢ 1 ⎥
1 2 ⎥⋅⎢ 1 1 1
TR = ⎢ − ⎥=⎢ − 2 ⎥
⎢ 1 3 ⎥ ⎢ 2 2 ⎥ ⎢ 2 2 ⎥
⎢ 1 ⎥ ⎢ ⎥ ⎢ ⎥
⎣ ⎦ 1 1 3 ⎥
⎢ ⎥ ⎢
⎢⎣ 1 ⎥⎦ ⎢⎣ 1 ⎥⎦
Rotation then tranlation, the TR matrix is the same to translating the rotated image, thus it comes
out kind of straightforward.

(d) Compute the matrix RT. Why is the result more complicated in this case?
Answer:

⎡ 1 1 ⎤ ⎡ 1 1 3 ⎤
⎢ − − ⎥ ⎢ − − − ⎥
⎢ 2 2 ⎥ ⎡ 1 1 ⎤ ⎢ 2 2 2 ⎥
⎢ 1 1 ⎥ ⎢ 1
⎥ ⎢
2 ⎥ 1 1 1 ⎥
RT = ⎢ − ⎥⋅⎢ =⎢ − − ⎥
⎢ 2 2 ⎥ ⎢ 1 3 ⎥ ⎢ 2 2 2 ⎥
⎢ ⎢
⎥ ⎣ 1 ⎥ ⎢ ⎥
1 ⎦ 1 3 ⎥
⎢ ⎥ ⎢
⎢⎣ 1 ⎥⎦ ⎢⎣ 1 ⎥⎦
Rotating a translated matrix will have effect to all of its components, which makes the matrix
different. Similarly, if we rotate an image after traslating it from origin to a new origin coordinate, the
image will be harder to calculate.

You might also like