Two dimensional viewing
Download
1 / 27

Two-Dimensional Viewing - PowerPoint PPT Presentation


  • 135 Views
  • Updated On :

Two-Dimensional Viewing. Jehee Lee Seoul National University. Viewing Pipeline. Two-Dimensional Viewing. Two dimensional viewing transformation From world coordinate scene description to device (screen) coordinates. Normalization and Viewport Transformation.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Two-Dimensional Viewing' - burton


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Two dimensional viewing

Two-Dimensional Viewing

Jehee Lee

Seoul National University



Two dimensional viewing1
Two-Dimensional Viewing

  • Two dimensional viewing transformation

    • From world coordinate scene description to device (screen) coordinates


Normalization and viewport transformation
Normalization and Viewport Transformation

  • World coordinate clipping window

  • Normalization square: usually [-1,1]x[-1,1]

  • Device coordinate viewport


Opengl 2d viewing
OpenGL 2D Viewing

  • Projection Mode

    • glMatrixMode(GL_PROJECTION);

  • GLU clipping-window function

    • gluOrtho2D(xwmin,xwmax,ywmin,ywmax);

    • Normalized to [-1,1]x[-1,1]

  • OpenGL viewport function

    • glViewport(xvmin,xvmax,yvmin,yvmax);

    • Rarely used because of GLUT device independent library


Clipping
Clipping

  • Remove portion of output primitives outside clipping window

  • Two approaches

    • Clip during scan conversion: Per-pixel bounds check

    • Clip analytically, then scan-convert the modified primitives


Two dimensional clipping
Two-Dimensional Clipping

  • Point clipping – trivial

  • Line clipping

    • Cohen-Sutherland

    • Cyrus-beck

    • Liang-Barsky

  • Fill-area clipping

    • Sutherland-Hodgeman

    • Weiler-Atherton

  • Curve clipping

  • Text clipping


Line clipping
Line Clipping

  • Basic calculations:

    • Is an endpoint inside or outside the clipping window?

    • Find the point of intersection, if any, between a line segment and an edge of the clipping window.

  • Both endpoints inside:

    trivial accept

  • One inside: find

    intersection and clip

  • Both outside: either

    clip or reject


Cohen sutherland line clipping

1001

1000

1010

Clipping window

0001

0010

0000

0101

0100

0110

Cohen-Sutherland Line Clipping

  • One of the earliest algorithms for fast line clipping

  • Identify trivial accepts and rejects by bit operations

< Region code for each endpoint >

above

below

right

left

Bit 4 3 2 1


Cohen sutherland line clipping1

1001

1000

1010

Clipping window

0001

0010

0000

0101

0100

0110

Cohen-Sutherland Line Clipping

  • Compute region codes for two endpoints

  • If (both codes = 0000 ) trivially accepted

  • If (bitwise AND of both codes  0000) trivially rejected

  • Otherwise, divide line into two segments

    • test intersection edges in a fixed order.

      (e.g., top-to-bottom, right-to-left)


Cohen sutherland line clipping2
Cohen-Sutherland Line Clipping

  • Fixed order testing and clipping cause needless clipping (external intersection)


Cohen sutherland line clipping3
Cohen-Sutherland Line Clipping

  • This algorithm can be very efficient if it can accept and reject primitives trivially

    • Clip window is much larger than scene data

      • Most primitives are accepted trivially

    • Clip window is much smaller than scene data

      • Most primitives are rejected trivially

  • Good for hardware implementation


Cyrus beck line clipping
Cyrus-Beck Line Clipping

  • Use a parametric line equation

  • Reduce the number of calculating intersections by exploiting the parametric form

  • Notations

    • Ei : edge of the clipping window

    • Ni : outward normal of Ei

    • An arbitrary point PEi on edge Ei



Cyrus beck line clipping2
Cyrus-Beck Line Clipping

  • Solve for the value of t at the intersection of P0P1 with the edge

    • Ni·[P(t) - PEi] = 0 and P(t) = P0 + t(P1 - P0)

    • letting D = (P1 - P0),

    • Where

      • Ni 0

      • D  0 (that is, P0 P1)

      • Ni· D  0 (if not, no intersection)


Cyrus beck line clipping3
Cyrus-Beck Line Clipping

  • Given a line segment P0P1, find intersection points against four edges

    • Discard an intersection point if t  [0,1]

    • Label each intersection point either PE (potentially entering) or PL (potentially leaving)

    • Choose the smallest (PE, PL) pair that defines the clipped line


Cyrus beck line clipping4
Cyrus-Beck Line Clipping

  • Cyrus-Beck is efficient when many line segments need to be clipped

  • Can be extended easily to convex polygon (rather than upright rectangle) clip windows


Liang barsky line clipping
Liang-Barsky Line Clipping

  • Liang-Barsky optimized Cyrus-Beck for upright rectangular clip windows

Q(x2.y2)

tR

tT

P(x1,y1)

tL

tB



General clipping window
General Clipping Window

  • Line clipping using nonrectangular polygon clip windows

    • Convex polygon

      • Cyrus-Beck algorithm can be readily extended

    • Concave polygon

      • Split the concave polygon into convex polygons

  • Vector Method for Concave Splitting

  • Calculate edge-vector cross products in a counterclockwise order

  • If any z component turns out to be negative, the polygon is concave


Polygon fill area clipping
Polygon Fill-Area Clipping

  • Polyline vs polygon fill-area

  • Early rejection is useful

Clipping Window

Bounding box of polygon fill area


Sutherland hodgman polygon clipping
Sutherland-Hodgman Polygon Clipping

  • Clip against 4 infinite clip edges in succession


Sutherland hodgman polygon clipping1
Sutherland-Hodgman Polygon Clipping

  • Accept a series of vertices (polygon) and outputs another series of vertices

  • Four possible outputs


Sutherland hodgman polygon clipping2
Sutherland-Hodgman Polygon Clipping

  • The algorithm correctly clips convex polygons, but may display extraneous lines for concave polygons


Weiler atherton polygon clipping
Weiler-Atherton Polygon Clipping

  • For an outside-to-inside pair of vertices, follow the polygon boundary

  • For an inside-to-outside pair of vertices, follow the window boundary in a clockwise direction


Weiler atherton polygon clipping1
Weiler-Atherton Polygon Clipping

  • Polygon clipping using nonrectangular polygon clip windows


Text clipping
Text Clipping

  • All-or-none text clipping

    • Using boundary box for the entire text

  • All-or-non character clipping

    • Using boundary box for each individual character

  • Character clipping

    • Vector font: Clip boundary polygons or curves

    • Bitmap font: Clip individual pixels