Viewing o Viewing and viewing space camera space

• Slides: 16

Viewing o Viewing and viewing space (camera space) o World space to viewing space transformation

World to Viewing Coordinates o Graphics display devices are 2 D rectangular screens. Hence we need to understand how to transform our 3 D world to a 2 D surface o Viewing the desired scene is analogous to taking pictures using a camera o We now need to world coordinates VIEWING TRANSFORMATION viewing coordinates

Camera Analogy o View is described in terms of: o o camera position in world coordinate system camera direction (viewing direction) camera orientation: usually defined by the up vector aperture size: field of view

View Coordinate System o specify a view reference point in the world coordinate system. This can be any point along the camera direction, or the camera position itself o specify the view plane normal N - this gives the camera, or Z direction o specify the view-up direction, V - this gives the camera up direction, or Y direction V y. W P 0 x. W z. W y. W N x. W z. W v’ P 0 v N n v=v’-(v. n) n

Viewing Coordinate System o We can construct a vector U perpendicular to both V and N, and this will correspond to the Xv axis. How? o We can define U as right, V as up, and N as towards the viewer: a right handed system U V=N o We can also define U as right, V as up and N as into the scene: a left handed system V U=N, in which bigger N values mean points are further away V o Open. GL is right handed U y. W P 0 x. W z. W N

View Coordinate System o Some systems (e. g. , Open. GL) allow you to specify a ‘look at’ point, Q, from which N is calculated as the direction to the ‘look at’ point from the view reference point y. W P 0 x. W z. W Q

World to Viewing o Objects must be viewed in the viewing space o This can be done by aligning the view coordinate system with world coordinate system, e. g. , view reference point is transformed to world origin, and U, V, N are aligned with X, Y, Z directions through rotations y (x 0, y 0, z 0) z x

World to Viewing y z o Translate view origin to world origin, then align U, V and N axes with X, Y and Z directions by rotation R = Rz. Ry. Rx o rotate around X to bring N into the X-Z plane o rotate around Y to align N with Z o rotate around Z to align V with Y V o An easier way to work out the rotation matrix R: U o U in world space should be (1, 0, 0) in view space o V should be (0, 1, 0) P 0 o N should be (0, 0, 1) N o So we have the following equations Ux 1. R*(Ux, Uy, Uz, 1)T = (1, 0, 0, 1) (Ux, Uy, Uz, 1)T = Uy T 2. R*(Vx, Vy, Vz, 1) = (0, 1, 0, 1) Uz T 3. R*(Nx, Ny, Nz, 1) = (0, 0, 1, 1) 1 x

World to Viewing Transformation o Remember U. U=1, U. V=0, U. N=0, V. N=0, so if we choose the rotation matrix as R= o The equations 1, 2, 3 will be satisfied o The rotation matrix is a “change of basis” matrix o So viewing transformation from world space to viewing space is: M = RT

What’s Pw in viewing coordinates? Intuitively, P in viewing coordinate is (-1, 1, 1), but how do we derive it? u z y Pw=(1, 1, 0) v n (0, 0, 1) u, v, n in world space: u=(-1, 0, 0) v=(0, 1, 0) n=(0, 0, -1) x 1. Translate view origin to world origin with translation vector (0, 0, -1) 2. Multiply Pw by matrix M below to align viewing axes with world axes -1 0 0 0 M = 0 1 0 0 -1 1 So Pw in viewing space is: Pv = M T Pw

Open. GL Viewing Coordinate System o The default camera is placed at the coordinate origin of world space (U aligned with the X axis, V aligned with Y, and N aligned with Z), looking along the negative z-direction, and the view plane is perpendicular to the viewing direction yv xv zv

Projection o We need to transform from a special viewing coordinate system (camera on z-axis pointing along the axis) into a projection coordinate system viewing coordinates PROJECTION TRANSFORMATION projection coordinates

Parallel Projection - Two types o In parallel projection, the observer position is at an infinite distance, so the projection lines are parallel o Orthographic parallel projection has view plane perpendicular to direction of projection o Oblique parallel projection has view plane at an oblique angle to direction of projection P 1 P 2 view plane

Parallel Projection Calculation looking along x-axis yv xv zv P(x, y, z) y. V viewing space o (xp, yp, d) d - z. V view plane y. P = y Similarly, x. P = x

Parallel Projection Calculation o So o x = xp o y = yp o z=d If view plane is xoy plane, Then d=0 o The projection transformation matrix is simply x xp 1. 1 yp 0 1 0 0 y d 0 0 d/z 0 z 1 0 0 0 1 1 = projection space 0 0 projection matrix 0 viewing space

Perspective Projection o In a perspective projection, object positions are projected onto the view plane along lines which converge at the observer, or Centre of Projection (COP) P 1 P 2 P 1’ camera P 2’ view plane o Perspective projection gives realistic views, but does not preserve proportions - projections of distant objects are smaller than projections of objects of the same size which are closer to the view plane (fore-shortening)