2D and 3D clipping.pdf

Embed Size (px)

Citation preview

  • 7/27/2019 2D and 3D clipping.pdf

    1/51

    Clipping

  • 7/27/2019 2D and 3D clipping.pdf

    2/51

    When?

  • 7/27/2019 2D and 3D clipping.pdf

    3/51

    2D clipping

  • 7/27/2019 2D and 3D clipping.pdf

    4/51

    2D clipping

    ? Part of the primitive is inside the window

    defined in WCS

    Remark: clipping is done to avoid the cost of

    future transformations on those parts of the

    primitives that are not visible in the image

  • 7/27/2019 2D and 3D clipping.pdf

    5/51

    Methods

    1. Analytic

    2. During the scan conversion

    3. Copy pixels from one memory region to

    another memory region

    Remark: Met 1 for lines and polygons, Met 2 for

    other primitives

  • 7/27/2019 2D and 3D clipping.pdf

    6/51

    Point clipping

    Suppose a rectangular window with the

    corners (xmin,ymin) and (xmax,ymax)

    P(x,y) is visible

    xmin

  • 7/27/2019 2D and 3D clipping.pdf

    7/51

    Simple alg. for line segments

    Suppose F=rectangular window; ? PQ/F

  • 7/27/2019 2D and 3D clipping.pdf

    8/51

    Acceptance / rejection tests

    Accept if both ends of the segment are visible

    Reject if both ends of the segment are un the

    same part of the window (left, right, top,

    bottom)

    Simple alg + tests = efficient alg when the no.

    of interior or exterior segments is big

  • 7/27/2019 2D and 3D clipping.pdf

    9/51

    Acceptance/rejection tests and coding

  • 7/27/2019 2D and 3D clipping.pdf

    10/51

    Examples

  • 7/27/2019 2D and 3D clipping.pdf

    11/51

    Cohen-Sutherland alg.

  • 7/27/2019 2D and 3D clipping.pdf

    12/51

    Example

  • 7/27/2019 2D and 3D clipping.pdf

    13/51

    Examples

  • 7/27/2019 2D and 3D clipping.pdf

    14/51

    Examples

  • 7/27/2019 2D and 3D clipping.pdf

    15/51

    Examples

  • 7/27/2019 2D and 3D clipping.pdf

    16/51

    Bisection algorithm

    Principle: if the tests for acceptance or

    rejection fail on PQ then PQ is divided in twosegments, PR, RQ, R=(P+Q)/2

    ? PR, PQ accepted/rejected

    Remark: segments are accepted or rejected

    at most after log2 N steps, where N is the

    dimension in pixels of the discretized version

    of the segment PQ

  • 7/27/2019 2D and 3D clipping.pdf

    17/51

    Parametric line clipping algorithm

    (Cyrus-Beck algorithm)

    Suppose:

    trigonometric sense

    An edge of the window is inside the window

    The normal N to an edge E is oriented towards

    window exterior

    The support line for a given segment P1P0 is

    P(t)=P0+(P1-P0)t, t in R.

    Suppose x0

  • 7/27/2019 2D and 3D clipping.pdf

    18/51

  • 7/27/2019 2D and 3D clipping.pdf

    19/51

    Cyrus-Beck algorithm

  • 7/27/2019 2D and 3D clipping.pdf

    20/51

  • 7/27/2019 2D and 3D clipping.pdf

    21/51

    CB alg - computations

  • 7/27/2019 2D and 3D clipping.pdf

    22/51

    Simplifying the computations

  • 7/27/2019 2D and 3D clipping.pdf

    23/51

    Nicholl-Lee-Nicholl algorithm

  • 7/27/2019 2D and 3D clipping.pdf

    24/51

    Code of NLN algorithm

  • 7/27/2019 2D and 3D clipping.pdf

    25/51

    Code of NLN algorithm

  • 7/27/2019 2D and 3D clipping.pdf

    26/51

    Code of NLN algorithm

  • 7/27/2019 2D and 3D clipping.pdf

    27/51

    Weiler-Atherton alg.

  • 7/27/2019 2D and 3D clipping.pdf

    28/51

    Polygon clipping

  • 7/27/2019 2D and 3D clipping.pdf

    29/51

    Polygon clipping

  • 7/27/2019 2D and 3D clipping.pdf

    30/51

    Polygon clipping

    Tests for acceptance/rejection: method of

    bounded aria by finding the smallest rectaglethat surrounds the polygon

    Sutherland-Hodgman algorithm:

    Divide-et-impera strategy

    No. stages = no. edges of the clipping polygon

    I: list of initial vertex

    O: list of final vertex

  • 7/27/2019 2D and 3D clipping.pdf

    31/51

    Bounded aria method

  • 7/27/2019 2D and 3D clipping.pdf

    32/51

    SH algorithm

  • 7/27/2019 2D and 3D clipping.pdf

    33/51

    SH Algorithm

  • 7/27/2019 2D and 3D clipping.pdf

    34/51

    SH Algorithm

  • 7/27/2019 2D and 3D clipping.pdf

    35/51

    SH algorithm

  • 7/27/2019 2D and 3D clipping.pdf

    36/51

    SH algorithm

  • 7/27/2019 2D and 3D clipping.pdf

    37/51

    SH algorithm

  • 7/27/2019 2D and 3D clipping.pdf

    38/51

    Liang Barsky algorithm

    Suppose F=rectangle, vertex {P1,P2,Pn}

    numbered in trigonometric order ? {P1,P2,Pn} defining the clipped polygon

    Interior region 2 = corner region

    Interior region 3 = edge region

    Remark: an edge is entering in a corner

    region => the corner is added to the outputlist

  • 7/27/2019 2D and 3D clipping.pdf

    39/51

    LB alg

  • 7/27/2019 2D and 3D clipping.pdf

    40/51

    LB alg: passing through a corner region

  • 7/27/2019 2D and 3D clipping.pdf

    41/51

    LB alg

  • 7/27/2019 2D and 3D clipping.pdf

    42/51

    LB alg

  • 7/27/2019 2D and 3D clipping.pdf

    43/51

    3d Clipping

  • 7/27/2019 2D and 3D clipping.pdf

    44/51

    3d clipping

  • 7/27/2019 2D and 3D clipping.pdf

    45/51

    3d clipping

    With respect to the viewing volume

    Methods: generalization from 2d->3d: Cohen-Sutherland, bisection, Cyrus-Beck

    Cohen-Sutherlang alg: using the canonic volume

  • 7/27/2019 2D and 3D clipping.pdf

    46/51

    3d clipping, perspective

  • 7/27/2019 2D and 3D clipping.pdf

    47/51

    CS Alg - codes

    Bit Canonic vol./ Canonic vol./

    parallel proj. perspective proj.

  • 7/27/2019 2D and 3D clipping.pdf

    48/51

    3d clipping

    l

  • 7/27/2019 2D and 3D clipping.pdf

    49/51

    CS alg - computations

    C B k l

  • 7/27/2019 2D and 3D clipping.pdf

    50/51

    Cyrus-Beck alg.

    CB l d

  • 7/27/2019 2D and 3D clipping.pdf

    51/51

    CB alg - code