Unformatted text preview:

3 D Transformations Last time we developed 2 D transformations But we re mainly interested in 3 D graphics So today we ll extend these tools to 3 D Scaling Translation in 3 D Looks pretty much the same as in 2 D just add on the z dimension to everything Scaling r 0 S 0 0 0 0 0 s 0 0 0 t 0 0 0 1 Translation Unfortunately rotation is not so simple 1 0 T 0 0 0 0 x 1 0 y 0 1 z 0 0 1 Euler Angles Rotation About Coordinate Axes 0 1 0 cos Rx 0 sin 0 0 0 sin cos 0 0 0 0 1 cos 0 Ry sin 0 0 sin 1 0 0 cos 0 0 0 0 0 1 cos sin Rz 0 0 sin cos 0 0 0 0 1 0 0 0 0 1 0 sin 0 0 0 1 Drawbacks of Euler Angles Drawback 1 Result is order dependent suppose we rotate about x then y y rotation is about transformed axis after x rotation is performed this gets confusing 0 1 0 cos Rx 0 sin 0 0 Drawback 2 Difficult to interpolate for animation want to interpolate angles resulting motion can be weird cos 0 Ry sin 0 Can produce gimbal lock cos sin Rz 0 0 cos 0 0 sin 1 0 0 cos 0 0 sin cos 0 0 0 0 0 1 0 0 0 0 1 0 0 1 Some Mathematical Definitions The dual matrix of a vector u 0 z y u z 0 x 0 y x can write vector cross product u v as matrix multiply u v The outer product of a vector u with itself x T uu y x z x 2 xy xz y z xy y 2 yz xz yz z 2 Rotation About Arbitrary Axis Let s suppose we have a unit direction vector x u y where x 2 y 2 z 2 1 z We can derive a rotation by a given angle about this axis R u uu T cos I uu T sin u This is the approach used by OpenGL glRotatef x y z Has many of the same interpolation problems as Euler angles Projection Mapping 3 D to 2 D Our scene models are in 3 D space and images are 2 D so we need some way of projecting 3 D to 2 D The fundamental approach planar projection first we define a plane in 3 D space this is the image plane or film plane then project scene onto this plane and map to the window viewport Need to address two basic issues how to define plane how to define mapping onto plane Orthographic Projection Arguably the simplest projection image plane is perpendicular to one of the coordinate axes project onto plane by dropping that coordinate x y z x y or x z or y z OpenGL glOrtho left right bottom top near far assumes image plane perpendicular to z axis in other words it s the xy plane projects points x y z x y also defines viewport mapping defines rectangle on xy plane this gets mapped to window top left bottom right Perspective Projection But we naturally see things in perspective objects appear smaller the farther away they are lenses bend and hence focus incoming light in orthographic projection all rays are parallel We ve been using pinhole camera models draw rays thru focal point and points on object some of these lines will intersect the image plane this defines our projection into 2 D all points along a ray project to same point can project lines by projecting endpoints d The Canonical Camera Configuration Want to derive perspective transformation in particular a matrix representation y x focal point image plane d First we fix a canonical camera focal point at origin looking along z axis image plane parallel to xy plane located distance d from origin called the focal length z Effect of Perspective Projection on Points We project points thru the line connecting them to the focal point given a point we want to know where this line hits the image plane y image plane z d focal point 0 0 0 object point x y z z Effect of Perspective Projection on Points We project points thru the line connecting them to the focal point given a point we want to know where this line hits the image plane Can easily compute this using similar triangles y focal point 0 0 0 image point d z x d z y d object point x y z z Perspective Projection as a Transformation This homogeneous matrix performs perspective projection 1 0 P 0 0 0 1 0 0 0 0 1 1 d 0 0 0 0 It s operation on any given point is 1 0 0 0 0 1 0 0 0 0 1 1 d 0 x x 0 y y 0 z z 0 1 z d Perspective Projection as a Transformation This homogeneous matrix performs perspective projection 1 0 P 0 0 0 1 0 0 0 0 0 0 1 0 1 0 d And when we do the homogeneous division we get exactly the point we want only keep x and y coordinates d x x z y d y z z z d d 1 Completing the Projection The image plane itself is infinite must map a rectangular region of it to the viewport defined by left right top bottom coordinates We also customarily define near far clipping planes these are expressed as distances from the viewpoint they should always be positive nothing nearer than near will be drawn don t want to draw things behind the image plane nothing further than far will be drawn distance far near should be small use fixed precision numbers to represent depth between them OpenGL glFrustum left right bottom top near far More Convenient Perspective Specification Could always use glFrustum left right bottom top near far this is certainly sufficient but it s inconvenient Generally want to use gluPerspective fovy aspect near far viewport is always centered about z axis specifies the field of view along the y axis the angle made by the sides of the frustum and the aspect ratio of the viewport this is just width height y z Viewing Volumes The sides of the viewport define an infinite pyramid focal point at apex extending outward through space Adding in the clipping planes we get a truncated pyramid this is called a frustum Can think of this as the viewing volume nothing outside of it is visible projection warps this to a rectangular prism Example gluPerspective in Action cot 2 0 P 0 0 0 0 cot 2 0 z1 z0 z0 z1 0 0 Y z0 0 2 z1 z0 z0 z1 0 0 1 z1 Z field of view fovy z0 z1 aspect ratio zNear and zFar 1 1 We Need More General Cameras So far we ve assumed a canonical camera configuration focal point at the origin image plane parallel to xy plane This …


View Full Document

U of I CS 418 - 3-D Transformations

Loading Unlocking...
Login

Join to view 3-D Transformations and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view 3-D Transformations and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?