110 likes | 225 Views
Viewing in 3D. Conceptual model of the 3D viewing process. 2D device coordinates. 3D world-coordinate output primitives. Clipped world coordinates. Clip against view volume. Project onto projection plane. Transform into viewport in 2D device coordinates for display. 3D Coordinate Systems.
E N D
Viewing in 3D Conceptual model of the 3D viewing process 2D device coordinates 3D world-coordinate output primitives Clipped world coordinates Clip against view volume Project onto projection plane Transform into viewport in 2D device coordinates for display 240-422 Computer Graphics : Viewing in 3D
3D Coordinate Systems y axis y axis z axis -1 +1 x axis x axis +1 -1 z axis Right-handed (for mathematics) Left-handed (for computer graphics) 240-422 Computer Graphics : Viewing in 3D
3D Primitives: Point & Line • Any point in 3D coordinate is defined by (x,y,z) • Any line in 3D coordinate is defined with 2 points: (x1, y1, z1) and (x2, y2, z2) • Line equations: or 240-422 Computer Graphics : Viewing in 3D
3D Primitives: Planes • A plane is specified as Ax + By + Cz + D = 0 (A, B, C, D are constants) or x + B1y + C1z + D1 = 0 (where B1 = B/A, C1 = C/A and D1 = D/A) • If we know 3 points (not all in a line), we can determine the plain equation from x1 + B1y1 + C1z1 + D1 = 0 x2 + B1y2 + C1z2 + D1 = 0 x3 + B1y3 + C1z3 + D1 = 0 Solving for B1, C1, D1 yields the plain equation 240-422 Computer Graphics : Viewing in 3D
3D Primitives: Planes (cont’d) • A plane can also be specified with a single point in the plane (xp, yp, zp) and the normal vector (direction perpendicular to the plane) [Nx, Ny, Nz] [Nx, Ny, Nz] (xp, yp, zp) Plane equation: Nx(x-xp) + Ny(y-yp) +Nz(z-zp) = 0 240-422 Computer Graphics : Viewing in 3D
Geometrical Projections Parallel: determined by Direction of Projection (DOP) (projectors are parallel—do not converge to an “eye” or COP) Perspective: determined by Center of Projection (COP) (in our diagrams the “eye”) 240-422 Computer Graphics : Viewing in 3D
Parallel Projection • Suppose the direction of projection is given by the vector [xp, yp, zp] and the image is to be projected onto the xy plane • If we have a point on the object at (x1, y1, z1), we wish to determine where the projected point (x2, y2) will lie. • Writing the equations for a line passing the point (x,y,z) and in the direction of projection: x = x1 + xpu y = y1 + ypu z = z1 + zpu 240-422 Computer Graphics : Viewing in 3D
Parallel Projection • Where does this line intersect the xy plane (z=0)? Since u = -z1/zp substituting this into the first two equations gives x2 = x1 - z1 (xp/zp) y2 = y1 - z1 (yp/zp) This can be written in matrix form 240-422 Computer Graphics : Viewing in 3D
Perspective Projection • The further an object is from the viewer, the smaller it appears • If the center of projection is at (xc, yc, zc) and the point on the object is (x1, y1, z1) then the project ray will be the line containing these points and will be given by x = xc + (x1-xc)u y = yc + (y1-yc)u z = zc + (z1-zc)u 240-422 Computer Graphics : Viewing in 3D
Perspective Projection • The projected point (x2, y2) will be the point where this line intersects the xy plane • For this intersection point (z=0), we can compute u u = -zc / (z1-zc) • Substituting into the first two equations gives or 240-422 Computer Graphics : Viewing in 3D
Perspective Projection • In matrix form 240-422 Computer Graphics : Viewing in 3D