Docsity

Two Dimensional viewing, Lecture notes of Computer Graphics

Partial preview of the text

Download Two Dimensional viewing and more Lecture notes Computer Graphics in PDF only on Docsity!

Two-Dimensional Viewing

Chapter 6

The Viewing Pipeline

  • Window
    • A world-coordinate area selected for display. defines what is to be viewed
  • Viewport
    • An area on a display device to which a window is mapped. defines where it is to be displayed
  • Viewing transformation
    • The mapping of a part of a world-coordinate scene to device coordinates.
  • A window could be a rectangle to have any orientation.

The Viewing Pipeline

The Viewing Pipeline

Viewing Coordinate Reference Frame

  • The reference frame for specifying the world-coordinate window. - Viewing-coordinate origin: P 0 = (x 0 , y 0 ) - View up vector V: Define the viewing yv direction

Window-to-Viewport Coordinate

Transformation

Workstation transformtion

Clipping Operations

  • Clipping
    • Identify those portions of a picture that are either inside or outside of a specified region of space.
  • Clip window
    • The region against which an object is to be clipped.
    • The shape of clip window
  • Applications of clipping
  • World-coordinate clipping

Line Clipping

  • (^) Possible relationships between line positions

and a standard rectangular clipping region

Before clipping after clipping

Line Clipping

  • (^) Possible relationships
    • (^) Completely inside the clipping window
    • (^) Completely outside the window
    • (^) Partially inside the window
  • (^) Parametric representation of a line x = x 1 + u(x 2 - x 1 ) y = y 1 + u(y 2 - y 1 )
  • (^) The value of u for an intersection with a

rectangle boundary edge

  • (^) Outside the range 0 to 1
  • (^) Within the range from 0 to 1

Cohen-Sutherland Line Clipping

  • Bit values in the region code
    • Determined by comparing endpoint coordinates to the clip boundaries - A value of 1 in any bit position: The point is in that relative position.
  • Determined by the following steps:
    • Calculate differences between endpoint coordinates and clipping boundaries.
    • Use the resultant sign bit of each difference calculation to set the corresponding bit value.

Cohen-Sutherland Line Clipping

  • The possible relationships:
    • Completely contained within the window
      • 0000 for both endpoints.
    • Completely outside the window
      • Logical and the region codes of both endpoints, its result is not 0000.
    • Partially

Liang-Barsky Line Clipping

  • (^) Parameters p and q are defined as p   x 1 p   x 2 p   y 3 p   y 4 1 1 min q  x  xw 2 max 1 q  xw  x 4 max 1 q  yw  y 3 1 min q  y  yw

Liang-Barsky Line Clipping

  • pk = 0, parallel to one of the clipping boundary
    • qk < 0, outside the boundary
    • qk >= 0, inside the parallel clipping boundary
  • pk < 0, the line proceeds from outside to the

inside

  • pk > 0, the line proceeds from inside to outside