Complete Guide to Cube Transformation & Viewing Coordinates

exam review questions n.w
1 / 25
Embed
Share

"Learn how to transform a cube in a world coordinate system to viewing coordinates, including locating the eye and performing viewing transformations. Understand the concepts of r, u, v vectors and their values in 3D graphics."

  • Cube
  • Transformation
  • Viewing Coordinates
  • 3D Graphics
  • World Coordinate

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

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. (2, 1, 0) (1, 1, 0) Y (2, 1, 1) (1, 1, 1) EYE (4, 0, 0) (1, 0, 0) (2, 0, 0) (0, 0, 0) X Z (2, 0, 1) (1, 0, 1) 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. (1, 1, 0) (2, 1, 0) Y (2, 1, 1) (1, 1, 1) EYE (4, 0, 0) (1, 0, 0) (2, 0, 0) (0, 0, 0) X Z (2, 0, 1) (1, 0, 1) 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. (2, 1, 0) (1, 1, 0) Y (2, 1, 1) (1, 1, 1) EYE (4, 0, 0) (1, 0, 0) (2, 0, 0) (0, 0, 0) X Z (2, 0, 1) (1, 0, 1) 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 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 1 0 0 -4 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

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

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

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

  10. 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.) Z (3,6,5) lookat (3,4,5) eye X (0, 0, 0) -Y

  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 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.) Z (3,6,5) lookat Step 1: Translate the eye to the origin (3,4,5) eye T(-3, -4, -5) X 1 0 0 -eye_x 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 1 0 0 -3 (0, 0, 0) -Y

  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 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.) Z (After translation to origin) Step 2: At this point the eye has been translated to the origin. Rotate everything into the negative z axis. lookat (0, 2, 0) Intuitively what do you need to do to this picture to have the eye looking at the lookat point down the negative z axis? X eye (0, 0, 0) Rotate clockwise around x by 90 degrees. Which is a negative rotation around x. Rotatex(-90) - Y

  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 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.) Z (After translation to origin) What is the viewing transform? Viewing Xform = Rotatex(-90) * T(-3, -4, -5) X eye (0, 0, 0) lookat (0, 0, -2) Y

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

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

  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 <0, 3, 4> and that the vector for the viewing direction is <0, -2, 3>. Is the triangle front facing or back facing?

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

Related


More Related Content