More Drawing Tools - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

More Drawing Tools

Description:

Main idea: fast computations based on comparing with max/min x, y values of window ... Compare endpoints to determine if they are in/out of the rectangle ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 8
Provided by: cis86
Category:

less

Transcript and Presenter's Notes

Title: More Drawing Tools


1
More Drawing Tools
  • ( Clipping)
  • www.cis.syr.edu/mohan/gra5.ppt

2
Clipping
  • To eliminate those parts of the object that lie
    outside the region being drawn
  • OpenGL does this automatically
  • Issues that arise in clipping algorithms occur in
    others also
  • Object clipping is generally treated as polygon
    clipping, based on line clipping

3
Cohen-Sutherland Clipper
  • A routine called clipSegment that performs
    clipping on a line segment and returns 0 iff the
    entire line segment lies outside the clipping
    window
  • Main idea fast computations based on comparing
    with max/min x, y values of window

4
First step trivial accept/reject
  • Compare endpoints to determine if they are in/out
    of the rectangle
  • Generate a 4-bit codeword for each endpoint,
    whose elements are T(1) if P.xltW.l, P.ygtW.t,
    P.xgtW.r, P.yltW.y, respectively (is the point P to
    the left/above/right/below the window W?)

5
Trivial accept/reject cases
  • If codewords for both endpoints are FFFF, then
    the line segment lies entirely inside the window,
    no work needs to be done.
  • If both codewords have a T in the same position,
    both points are to the left/above/right/below the
    window, no work needs to be done.
  • Otherwise, successively chop the given line
    segment using the window boundary lines,
    eliminating clipped out part of the segment.

6
Computing the intersection
  • Given end points p1, p2, the intersection of the
    line segment with right window border has
    x-coordinate the same as W.r, and y-coordinate
    obtained by similarity of triangles (Fig.3.22)
  • (p1.y-p2.y)/(p1.x-p2.x) (A.y-p2.y)/(W.r-p2.x)

7
Procedure clipSegment()
  • Cf. Fig.3.23
Write a Comment
User Comments (0)
About PowerShow.com