1 / 44

Viewing Transformation

Viewing Transformation. Tong-Yee Lee. Changes of Coordinate System. World coordinate system. Camera (eye) coordinate system. Default Camera Position and Orientation. The default camera is with eye at the origin (0,0,0) and the axis of the pyramid aligned with the z-axis. The eye is looking

adara
Download Presentation

Viewing Transformation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Viewing Transformation Tong-Yee Lee

  2. Changes of Coordinate System World coordinate system Camera (eye) coordinate system

  3. Default Camera Position and Orientation The default camera is with eye at the origin (0,0,0) and the axis of the pyramid aligned with the z-axis. The eye is looking down the negative z-axis.

  4. In this equation, a is world coordinate, B will convert a to b (in another coordinate system)

  5. Why B is orthonormal? In above equation, 0 is due to vi.vj=0 i!=j

  6. b1=Bw->1aw • aw=Bw->1Tb1=B-w->1b1 • b2=Bw->2aw • aw=Bw->2Tb2=B-w->2b2 • B-w->1b1=B-w->2b2 • Bw->1B-w->1b1= Bw->1B-w->2b2 • b1= Bw->1B-w->2 b2= Bw->1B2->w b2

  7. Consider a special case as v1=(1,0,0), v2=(0,1,0) and v3(0,0,1)

  8. a is coordinate in (v1,v2,v3) system (usually is world coordinate) b is coordinate in (u1,u2,u3) system B is easily remembered by carefully checking B The first row: u1 projects on three axes v1,v2,v3 The second row: u2 projects on three axes v1,v2,v3 The third row: u3 projects on three axes v1,v2,v3 How about B’ for c is coordinate in (w1,w2,w3) for b converted to c? (i.e. c=B’b) This is same as previous matrix composition by way of transforming to world coordinate

  9. X axis vector Y axis vector Z axis vector

  10. Intuitive Camera Specification

  11. Not easy for user to pick up exact up vector!! So, we compute v automatically from up vector.

  12. b a n b’ n b

  13. b a n • Another way ……………….. • a = b’ x n • b = n x a

  14. v1=(1,0,0), v2=(0,1,0) and v3(0,0,1)

  15. Note that matrix storage order is column major in OpenGL

  16. u (i.e., x) axis n (i.e.,z) axis v (i.e., y) axis Treat yourself (viewer) as a airplane heading to –Zc Note that: as a viewer is moving, the object is moving in opposite direction on the viewing plane!!

  17. This is z-like rotation

  18. v’ n’ n u n’ v n u’ This is x-like rotation This is y-like rotation

  19. How about pitch() and yaw()? 7.3.1. Implementing pitch() and yaw(). void Camera :: pitch (float angle) { // pitch the camera through angle degrees around U float cs = cos(3.14159265/180 * angle); float sn = sin(3.14159265/180 * angle); Vector3 t(v); // remember old v v.set(cs*t.x + sn*n.x, cs*t.y + sn*n.y, cs*t.z + sn*n.z); n.set(-sn*t.x + cs*n.x, -sn*t.y + cs*n.y, -sn*t.z + cs*n.z); setModelViewMatrix(); } void Camera :: yaw (float angle) { // yaw the camera through angle degrees around V float cs = cos(3.14159265/180 * angle); float sn = sin(3.14159265/180 * angle); Vector3 t(n); // remember old v n.set(cs*t.x + sn*u.x, cs*t.y + sn*u.y, cs*t.z + sn*u.z); u.set(-sn*t.x + cs*u.x, -sn*t.y + cs*u.y, -sn*t.z + cs*u.z); setModelViewMatrix(); } • Same stories as roll().

  20. How about slide() • Sliding a camera means to move it along one of its own axes-that is in the u,v,n direction-without rotating it. • Along n means forward or backward • Along u is left and right • Along v is up and down • Assume slide(delU, delV, delN)

  21. Flythrough a Scene!!!

More Related