Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 376 Introduction to Computer Graphics 02 / 21 / 2007 Instructor: Michael Eckmann.

Similar presentations


Presentation on theme: "CS 376 Introduction to Computer Graphics 02 / 21 / 2007 Instructor: Michael Eckmann."— Presentation transcript:

1 CS 376 Introduction to Computer Graphics 02 / 21 / 2007 Instructor: Michael Eckmann

2 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Today’s Topics Questions? Projections –parallel and perspective projections Perspective projection matrix derivation Orthogonal projection matrix derivation Comments on altering Bresenham's line algorithm to add antialiasing capability View volumes

3 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Projection terminology Projection –transformation of points in a coordinate system of dimension n to a coordinate system of dimension less than n (from Foley, VanDam, Feiner, Hughes) Planar Geometric Projections –planar means we're projecting onto a plane (2d) --- this plane is called the projection plane (also sometimes the view plane) –geometric means we're using straight (not curved) projectors (projectors are the blue dotted lines on the slide after the next.) –Many projections in cartography are non planar or non geometric. When we use the word projection from here on out, we're talking about Planar Geometric Projection.

4 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Projection types Breakdown of Planar Geometric Projections: –Parallel orthographic –top –front –side –axonometric isometric other oblique –cabinet –cavalier –other –Perspective one point two point three point

5 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Projection types There are many subclasses of projections Projections can be either parallel or perspective. The distance between the center of projection (CoP) (= convergence point in the diagram) and the projection plane is infinity for parallel projections and is finite for perspective projections.

6 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Projection types Perspective projections can be 1 (vanishing) point, 2 point or 3 point. Diagrams below show 1 point and 2 point. 3 point perspective would occur if in the 2 point perspective diagram, the vertical lines instead of being parallel, vanished to some point (above or below).

7 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Projection types The 1 point perspective projection is made when one of the coordinate axes is cut by the projection plane. 2 point is when 2 coordinate axes are cut by the projection plane. And 3 point when all 3 coordinate axes are cut by the projection plane. So, in other words, the 1, 2 and 3 point projections are generated by situating the view plane such that it intersects with either 1, 2 or 3 principle axes (x, y and/or z), respectively.

8 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Perspective Projection Parallel lines in the world appear parallel in the projection (view plane) if they are parallel to the view plane (e.g. see vertical lines in the figure b) and c) a few slides ago.) Any lines that are parallel to each other in the world, but are not parallel to the view plane will converge to a vanishing point. There are an infinity of vanishing points, because there are an infinity of line directions. There is 1 center of projection for any perspective projection. See handout.

9 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Projection types Parallel projections can be orthographic or oblique. Orthographic (aka orthogonal) are those that have the projectors perpendicular (normal) to the view plane. Oblique are those that have the projectors not normal to the view plane.

10 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Projection types Orthographic projections can be further divided into top (aka plan), front elevation, side elevation or axonometric. The top, front and side elevation projections are typically used in drafting (Engineering or Architectural drawings.) Think of a view of a building where the projectors are parallel to each other and perpendicular to the view plane and the view plane is either parallel to the top, front or side of a building, and hence only one face of the building will displayed in the view plane. Axonometric projections are orthographic and have the view plane situated so that it is not orthogonal to a principle axis. Isometric projection is the kind of axonometric projection where three faces are displayed on the view plane and the view plane cuts the 3 coordinate axes at equal distances from the origin.

11 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Projection types Oblique parallel projections are those that have their projectors not normal to the view plane. Two common kinds of oblique projections are cavalier and cabinet. Cavalier are those whose projector angle is 45 degrees with the projection plane. Cabinet are those whose projector angle is about 63.4 degrees (tan -1 2) with the projection plane. These appear more realistic than cavalier, because lines that are perpendicular to the viewing plane are projected at half length.

12 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Projection types Recap on the breakdown of Planar Geometric Projections: –Parallel (CoP at infinity) orthographic (projectors normal to the view plane) –top (view plane parallel to x-z plane, orthogonal to y-axis) –front –side –axonometric (see more than one face in the view plane) isometric (see three faces in view plane and view plane intersects the 3 coordinate axes at the same distance from the origin.) other oblique (projectors not normal to the view plane) –cabinet (projector angle is 45 degrees) –cavalier (projector angle is about 63.4 degrees) –other –Perspective (CoP is finite) one point (vanishing point only in one principle direction) two point (vanishing points in two principle directions) three point (vanishing points in three principle directions)

13 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Perspective Matrix Derivation Now we'll derive the matrix for a perspective projection onto a viewing plane. Assume that the viewing plane is at z=0 Assume that the center of projection is at (0, 0, -d) Given a point in 3 space, what is its projected coordinates on the plane at z=0? Let's draw a diagram on the board.

14 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Perspective Matrix Derivation Using the parametric equation of a line, the line will go through CoP = (0, 0, -d) and through the point in space that we are projecting P = (x,y,z). The projected point P proj = (x proj, y proj, z proj ), lies on the z=0 plane. x proj = x + t(0-x) = x – tx y proj = y + t(0-y) = y – ty z proj = z + t(-d-z) = z – t ( d+ z) = 0, so t=z/(d+z) substitute t into the x proj and y proj equations to get: x proj = x – x z / (d+z) = (dx + zx – xz) / (d+z) = x / (1 + (z/d)) y proj = y / (1 + (z/d)) How to use this information to generate a matrix that performs the perspective projection?

15 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 One Point Perspecitve Perspective projection onto z=0 plane with CoP at (0,0,-d). [ 1 0 0 0 ] [ x ] [ x ] [ 0 1 0 0 ] [ y ] = [ y ] [ 0 0 0 0 ] [ z ] [ 0 ] [ 0 0 1/d 1 ] [ 1 ] [ (z/d) + 1 ]

16 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Orthographic Projection What do you think a matrix for an orthographic projection onto the z=0 plane would look like? Orthographic means that the direction of the projectors is parallel to z-axis since the z=0 plane is orthogonal to the z- axis. The difference is that we do not have a finite CoP. Given a point in the world P = (x,y,z), what will be its projected point on the z=0 plane? So, what does the matrix look like?

17 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Orthographic Projection [ 1 0 0 0 ] [ x ] [ x ] [ 0 1 0 0 ] [ y ] = [ y ] [ 0 0 0 0 ] [ z ] [ 0 ] [ 0 0 0 1 ] [ 1 ] [ 1 ]

18 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Antialiasing Bresenham This picture only tells part of the story

19 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Antialiasing Bresenham The picture only tells part of the story It's clear from the picture that dlower = Ydesired – Yk dupper = 1 - dlower Even though we're dealing with slopes of less than 1 and > 0, there are other cases that that picture doesn't display. case 1) when dlower < 0 case 2) when dupper < 0 case 3) shown on last slide when dlower and dupper both > 0 case 4) when line goes right through center of a pixel Picture on the board.

20 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Antialiasing Bresenham Furthermore there's the issue of which two pixels to turn on y is the y-coordinate that Bresenham calculates for this step The two to turn on is dependent on which case we're in case 1) when dlower < 0 the two pixels y coordinates are y & y – 1 case 2) when dupper < 0 the two pixels y coordinates are y & y + 1 case 3) shown on last slide when dlower and dupper both > 0 if Bresenham would've kept y the same then the two pixels y coordinates are y & y + 1 else y & y – 1

21 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Antialiasing Bresenham case 4) when actual line goes right through the center of a pixel that happens when the values of dupper and dlower are 0 and 1 (or really close when dealing with floating points) so you can test it by taking the absolute value of the difference between the two and test if this is really close to 1 Anyway, when this happens we only want to turn on one pixel (the one with the y coordinate that Bresenham calculated) at full intensity

22 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Antialiasing Bresenham As for the intensities of the two pixels –case 1) when dlower < 0 example: dlower = -.2 and dupper = 1.2 make intens1 = 1+ dlower (e.g. 0.8) make intens2 = 1 – intens1 (e.g. 0.2) case 2) when dupper < 0 example: dlower = 1.1 and dupper = -0.1 make intens1 = 1+ dupper (e.g. 0.9) make intens2 = 1 – intens1 (e.g. 0.1) case 3) example: dlower = 0.4 and dupper = 0.6 OR example: dlower = 0.7 and dupper = 0.3 make intens1 = dupper (e.g. 0.6) make intens2 = 1 – intens1 (e.g. 0.4)

23 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 View Volumes Assuming a rectangular viewport and given the CoP (aka Projection Reference Point PRP) we have an infinite view volume. Drawing on board. So, the view volume contains the portion of the world that may be displayed in the viewport --- what is not in the volume is clipped out. To limit the processing (and limit what will be displayed), we typically reduce the view volume to a finite volume. We define 2 planes – Front and Back clipping planes (aka hither and yon). Now the finite view volume is the volume contained within the pyramid between the two clipping planes.

24 Michael Eckmann - Skidmore College - CS 376 - Spring 2007 View Volumes Given a view volume and a projection (e.g. a perspective or parallel projection matrix), objects can be clipped to the view volume by solving simultaneous equations for intersections with the projectors with the view plane. This is computation intensive. A more efficient way is clip against a volume that is easier to clip against. For perspective projections this volume (called the canonical view volume for perspective) is defined by the planes: x = z, x = -z, y = z, y = -z, z = -z min, z = -1 For parallel projection's the canonical view volume is x = 1, x = -1, y = 1, y = -1, z = 0, z = -1


Download ppt "CS 376 Introduction to Computer Graphics 02 / 21 / 2007 Instructor: Michael Eckmann."

Similar presentations


Ads by Google