exam review questions. problem: a cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1,...

25
Exam Review Questions

Upload: daniel-dean

Post on 03-Jan-2016

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

Exam Review Questions

Page 2: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

Problem: A cube has vertices with world coordinates:

(1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2, 1, 0)

The eye (or camera) is at (4, 0, 0).

The LookAt point is directed at (2, 0, 0).

a. Sketch the cube, and locate the eye in a world coordinate system. Show the LookAt vector. Show the x,y,z axes and the origin.

b. What do r, u, and v represent, and what are their values?

c. Perform a viewing transformation. What are the cube vertices in viewing coordinates?

Page 3: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

EYE (4, 0, 0)

(1, 1, 0) (2, 1, 0)

(2, 1, 1)

(2, 0, 1)(1, 0, 1)

(1, 1, 1)

(2, 0, 0)(1, 0, 0)X

Y

Z

(0, 0, 0)

Sketch the cube, and locate the eye in a world coordinate system. Show the LookAt vector. Show the x,y,z axes and the origin.

Page 4: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

EYE (4, 0, 0)

(1, 1, 0) (2, 1, 0)

(2, 1, 1)

(2, 0, 1)(1, 0, 1)

(1, 1, 1)

(2, 0, 0)(1, 0, 0)X

Y

Z

(0, 0, 0)

What do r, u, v, and up represent, and what are their values?a. v is the unit vector that points from the eye to the the lookat point.

a. v=(lookat-eye)/||lookat-eye|| = (-1, 0, 0)b. up points up in the world coordinate system

a. up = (0, 1, 0)c. r is the unit vector orthogonal to the plane formed by the v and up vectors.

a. r = v x up / || v x up|| = (0, 0, -1)d. u is the unit vector orthogonal to the plane formed by the r and v vectors

a. u = r x v = (0, 1, 0)

Page 5: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

EYE (4, 0, 0)

(1, 1, 0) (2, 1, 0)

(2, 1, 1)

(2, 0, 1)(1, 0, 1)

(1, 1, 1)

(2, 0, 0)(1, 0, 0)X

Y

Z

(0, 0, 0)

To transform this to view coordinates:1) Translate the eye point to the origin2) Rotate the view vector onto the negative z-axis

Page 6: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

1. Translate the eye point to the origin Eye is at (4, 0, 0). What is the translation matrix which will do that?

1 0 0 -eye_x 1 0 0 -4 0 1 0 eye_y = 0 1 0 0 0 0 1 eye_z 0 0 1 0 0 0 0 1 0 0 0 1

2. Now the eye is at the origin. We want the eye to look down the –z axis, so what transformation does that? rx ry rz 0 0 0 -1 0 ux uy uz 0 = 0 1 0 0 -vx –vy -vz 0 1 0 0 0 0 0 0 1 0 0 0 1

|0 0 -1 0| | 1 0 0 -4| |vertex_world_x] |0 0 -1 0| |vertex_world_x| |0 1 0 0| | 0 1 0 0| |vertex_world_y| = |0 1 0 0| |vertex_world_y| |1 0 0 0| | 0 0 1 0| |vertex_world_z| |1 0 0 -4| |vertex_world_z| |0 0 0 1| | 0 0 0 1| | 1 | |0 0 0 1| | 1 |

Results: (0, 0, -3, 1) (0, 0, -2, 1) (0, 1, -3, 1) (0, 1, -2, 1) (-1, 0, -3, 1) (-1, 0, -2, 1) (-1, 1, -3, 1) (0, 1,-2, 1) Where the eye at (0,0,0) looking down the negative z axis

(1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2, 1, 0)

Page 7: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: Look at the code sample. Supply the missing keywords (marked “???”). Why did you select the keywords you did?

<script id="shader-vs" type="x-shader/x-vertex">

??? vec3 aVertexPosition;

??? vec4 aVertexColor;

??? mat4 uMVMatrix;

??? vec4 vColor;

void main(void) { gl_Position = uMVMatrix*vec4(aVertexPosition, 1.0);

vColor = aVertexColor; } </script>

<script id="shader-fs" type="x-shader/x-fragment">

precision mediump float;

??? vec4 vColor;

void main(void) { gl_FragColor = vColor; } </script>

Page 8: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: Look at the code sample. Supply the missing keywords.<script id="shader-vs" type="x-shader/x-vertex">

attribute vec3 aVertexPosition;

attribute vec4 aVertexColor;

uniform mat4 uMVMatrix;

varying vec4 vColor;

void main(void) { gl_Position = uMVMatrix*vec4(aVertexPosition, 1.0);

vColor = aVertexColor; } </script>

<script id="shader-fs" type="x-shader/x-fragment">

precision mediump float;

varying vec4 vColor;void main(void)

{ gl_FragColor = vColor; }</script>

Page 9: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: In a right handed world coordinate system where the x and y are horizontal axes and z is the vertical axis, with positive z in the up direction, let the eye be at the point (3,4,5) looking at the point (3,6,5). Indicate the viewing transformation below for viewing coordinates with the eye at the origin looking down the negative z axis, as the product of rotation and translation matrices. You should use Rotatex(θ) (or Rotatey(θ) / Rotatez(θ)) to denote a 4x4 homogeneous rotation matrix about x axis (or y / z) by θ degrees, and T(a,b,c) to denote a 4x4 homogeneous translation matrix in the direction (a,b,c). (Hint: show your work. Draw pictures. Take your time. Use your right hand.)

Page 10: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: In a right handed world coordinate system where the x and y are horizontal axes and z is the vertical axis, with positive z in the up direction, let the eye be at the point (3,4,5) looking at the point (3,6,5). Indicate the viewing transformation below for viewing coordinates with the eye at the origin looking down the negative z axis, as the product of rotation and translation matrices. You should use Rotatex(θ) (or Rotatey(θ) / Rotatez(θ)) to denote a 4x4 homogeneous rotation matrix about x axis (or y / z) by θ degrees, and T(a,b,c) to denote a 4x4 homogeneous translation matrix in the direction (a,b,c). (Hint: show your work. Draw pictures. Take your time. Use your right hand.)

X

Z

-Y

(0, 0, 0)

(3,6,5) lookat

(3,4,5) eye

Page 11: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: In a right handed world coordinate system where the x and y are horizontal axes and z is the vertical axis, with positive z in the up direction, let the eye be at the point (3,4,5) looking at the point (3,6,5). Indicate the viewing transformation below for viewing coordinates with the eye at the origin looking down the negative z axis, as the product of rotation and translation matrices. You should use Rotatex(θ) (or Rotatey(θ) / Rotatez(θ)) to denote a 4x4 homogeneous rotation matrix about x axis (or y / z) by θ degrees, and T(a,b,c) to denote a 4x4 homogeneous translation matrix in the direction (a,b,c). (Hint: show your work. Draw pictures. Take your time. Use your right hand.)

Step 1: Translate the eye to the origin

T(-3, -4, -5)

1 0 0 -eye_x 1 0 0 -3 0 1 0 -eye_y = 0 1 0 -4 0 0 1 -eye_z 0 0 1 -5 0 0 0 1 0 0 0 1

X

-Y

(0, 0, 0)

(3,6,5) lookat

(3,4,5) eye

Z

Page 12: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: In a right handed world coordinate system where the x and y are horizontal axes and z is the vertical axis, with positive z in the up direction, let the eye be at the point (3,4,5) looking at the point (3,6,5). Indicate the viewing transformation below for viewing coordinates with the eye at the origin looking down the negative z axis, as the product of rotation and translation matrices. You should use Rotatex(θ) (or Rotatey(θ) / Rotatez(θ)) to denote a 4x4 homogeneous rotation matrix about x axis (or y / z) by θ degrees, and T(a,b,c) to denote a 4x4 homogeneous translation matrix in the direction (a,b,c). (Hint: show your work. Draw pictures. Take your time. Use your right hand.)

X

Z

- Y

(0, 0, 0)eye

Step 2: At this point the eye has been translated to the origin. Rotate everything into the negative z axis.lookat

Intuitively… what do you need to do to this picture to have theeye looking at the lookat point down the negative z axis?

Rotate clockwise around x by 90 degrees.Which is a negative rotation around x. Rotatex(-90)

(0, 2, 0)

(After translation to origin)

Page 13: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: In a right handed world coordinate system where the x and y are horizontal axes and z is the vertical axis, with positive z in the up direction, let the eye be at the point (3,4,5) looking at the point (3,6,5). Indicate the viewing transformation below for viewing coordinates with the eye at the origin looking down the negative z axis, as the product of rotation and translation matrices. You should use Rotatex(θ) (or Rotatey(θ) / Rotatez(θ)) to denote a 4x4 homogeneous rotation matrix about x axis (or y / z) by θ degrees, and T(a,b,c) to denote a 4x4 homogeneous translation matrix in the direction (a,b,c). (Hint: show your work. Draw pictures. Take your time. Use your right hand.)

X

Z

Y

(0, 0, 0)eye

lookat(0, 0, -2)

(After translation to origin)

* T(-3, -4, -5)Viewing Xform = Rotatex(-90)

What is the viewing transform?

Page 14: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: The polygon below can be drawn as a triangle strip. List the vertices in the order as they are used to draw the polygon.

Page 15: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: The polygon below can be drawn as a triangle strip. List the vertices in the order as they are used to draw the polygon.

1: F, C, B, E, D, A

2: A, D, E, B, C, F

Page 16: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: 3D transformation. Find a transformation matrix that will simultaneously squash by ½ along the z axis and stretch by 5 along the x axis.

Page 17: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: 3D transformation. Find a transformation matrix that will simultaneously squash by ½ along the z axis and stretch by 5 along the x axis

|a 0 0 0| |x| |ax| |0 b 0 0| |y| = |by| |0 0 c 0| |z| |cy| |0 0 0 1| |1| |1 |

|5 0 0 0| |0 1 0 0| |0 0 0.5 0| |0 0 0 1|

Page 18: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: 3D transformation. Find a transformation matrix which performs: Rotation of 90 around the z axis, then translate by 5 units along the y axis, then scales the object by 2 units in all directions.

Page 19: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: 3D transformation. Find a transformation matrix which performs: Rotation of 90 around the z axis, then translate by 5 units along the y axis, then scales the object by 2 units in all directions.

Rotation of 90 degrees around z: (1st transformation, T1) |cos90 -sin90 0 0| |0 -1 0 0| |sin90 cos90 0 0| = |1 0 0 0| | 0 0 1 0| |0 0 1 0| | 0 0 0 1| |0 0 0 1|

Page 20: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: 3D transformation. Find a transformation matrix which performs: Rotation of 90 around the z axis, then translate by 5 units along the y axis, then scales the object by 2 units in all directions.

Translate 5 units along y axis: (2nd transformation, T2) |1 0 0 a| |1 0 0 0| |0 1 0 b| = |0 1 0 5| |0 0 1 0| |0 0 1 0| |0 0 0 1 | |0 0 0 1|

Page 21: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: 3D transformation. Find a transformation matrix which performs: Rotation of 90 around the z axis, then translate by 5 units along the y axis, then scales the object by 2 units in all directions.

Scale by 2 on all axes: (3rd transformation, T3) |a 0 0 0| |2 0 0 0| |0 b 0 0| = |0 2 0 0| |0 0 c 0| |0 0 2 0| |0 0 0 1 | |0 0 0 1|

Page 22: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: 3D transformation. Find a transformation matrix which performs: Rotation of 90 around the z axis, then translate by 5 units along the y axis, then scales the object by 2 units in all directions.

Put them all together. First rotate, then translate, then scale. Note the order that produces this. T3 T2 T1

Page 23: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: 3D transformation. Supposed a triangle has a normal vector of <0, 3, 4> and that the vector for the viewing direction is <0, -2, 3>.

Is the triangle front facing or back facing?

Page 24: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,

• Problem: 3D transformation. Supposed a triangle has a normal vector of <0, 3, 4> and that the vector for the viewing direction is <0, -2, 3>.

Is the triangle front facing or back facing?

Take the dot product. Is the dot product positive or negative? Positive

A positive dot product indicates a back facing polygon. (The view vector runs in the direction of eyepoint to the polygon)

Therefore the triangle is back facing.

Page 25: Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,