Presentation is loading. Please wait.

Presentation is loading. Please wait.

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,

Similar presentations


Presentation on theme: "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,"— Presentation transcript:

1 Exam Review Questions

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?

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

4 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)

5 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 origin 2)Rotate the view vector onto the negative z-axis

6 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)

7 Problem: Look at the code sample. Supply the missing keywords (marked “???”). Why did you select the keywords you did? ??? vec3 aVertexPosition; ??? vec4 aVertexColor; ??? mat4 uMVMatrix; ??? vec4 vColor; void main(void) { gl_Position = uMVMatrix*vec4(aVertexPosition, 1.0); vColor = aVertexColor; } precision mediump float; ??? vec4 vColor; void main(void) { gl_FragColor = vColor; }

8 Problem: Look at the code sample. Supply the missing keywords. attribute vec3 aVertexPosition; attribute vec4 aVertexColor; uniform mat4 uMVMatrix; varying vec4 vColor; void main(void) { gl_Position = uMVMatrix*vec4(aVertexPosition, 1.0); vColor = aVertexColor; } precision mediump float; varying vec4 vColor;void main(void) { gl_FragColor = vColor; }

9 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 Rotate x (θ) (or Rotate y (θ) / Rotate z (θ)) 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.)

10 X Z -Y (0, 0, 0) (3,6,5) lookat (3,4,5) eye

11 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 Rotate x (θ) (or Rotate y (θ) / Rotate z (θ)) 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

12 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 Rotate x (θ) (or Rotate y (θ) / Rotate z (θ)) 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 the eye looking at the lookat point down the negative z axis? Rotate clockwise around x by 90 degrees. Which is a negative rotation around x. Rotate x (-90) (0, 2, 0) (After translation to origin)

13 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 Rotate x (θ) (or Rotate y (θ) / Rotate z (θ)) 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 = Rotate x (-90) What is the viewing transform?

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

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

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

17 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|

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

19 Rotation of 90 degrees around z: (1 st 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|

20 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|

21 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|

22 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

23 Problem: 3D transformation. Supposed a triangle has a normal vector of and that the vector for the viewing direction is. Is the triangle front facing or back facing?

24 Problem: 3D transformation. Supposed a triangle has a normal vector of and that the vector for the viewing direction is. 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.

25


Download ppt "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,"

Similar presentations


Ads by Google