SlideShare a Scribd company logo
CSE 423 Computer
    Graphics
             Clipping
•   Cohen Sutherland Algorithm (Line)
•   Cyrus-Back Algorithm (Line)
•   Sutherland-Hodgeman Algorithm (Polygon)
•   Cohen Sutherland Algorithm (3d)
Point Clipping
       clip
 rectangle                          y = y max   ( x max , y max )




        x = x min                                         x = x max




              ( x min , y min )     y = y min



For a point (x,y) to be inside the clip rectangle:
                                  xmin ≤ x ≤ xmax
                                  ymin ≤ y ≤ ymax
Point Clipping
       clip
 rectangle                            y = y max   ( x max , y max )



                                   (x 1, y 1)
        x = x min                                           x = x max




              ( x min , y min )       y = y min



For a point (x,y) to be inside the clip rectangle:
                                  xmin ≤ x ≤ xmax
                                  ymin ≤ y ≤ ymax
Line Clipping




       clip
 rectangle




              Cases for clipping lines
Line Clipping



                 B                   B


                 A                   A


       clip
 rectangle




              Cases for clipping lines
Line Clipping

                              D


                     D'                  D'


                          C                   C
                 B                   B


                 A                   A


       clip
 rectangle




              Cases for clipping lines
Line Clipping

              F
                               D


                      D'                 D'


                           C                  C
                  B                  B
  E

                  A                  A


       clip
 rectangle




              Cases for clipping lines
Line Clipping

              F
                                   D


                         D'                         D'


                              C                          C
                     B                      H   B
  E
                                       H'                     H'
                     A                          A
                              G'                         G'

       clip              G
 rectangle




                  Cases for clipping lines
Line Clipping

              F
                                   D


                         D'                                   D'


                              C                                    C
                     B                      H             B
  E
                                       H'             J                 H'
                     A                                    A
                              G'                                   G'

                                                 J'
       clip              G
 rectangle                                  I'

                                   I




                  Cases for clipping lines
Line Clipping
               Clipping Lines by Solving Simultaneous Equations

  (x 1, y 1)                                                                     (x 1, y 1)




(x , y )       (x b, y b)           (x a, y a)           (x b , y b)           (x , y )           (x a, y a)




      (x 0, y 0)                                                                     (x 0, y 0)




               (x c, y c)           (x d, y d)           (x c, y c)                               (x d , y d)



                             clip                                       clip
                       rectangle                                  rectangle

            x = x0 +tline ( x1 − x0 ),           y = y0 +tline ( y1 − y0 )
            x = xa +t edge ( xb − xa ),           y = ya +t edge ( yb − y a )
Cohen-Sutherland Algorithm
The Cohen-Sutherland Line-Clipping
Algorithm performs initial tests on a line to
determine whether intersection calculations
can be avoided.
1.   First, end-point pairs are checked for Trivial
     Acceptance.
2.   If the line cannot be trivially accepted, region
     checks are done for Trivial Rejection.
3.   If the line segment can be neither trivially
     accepted or rejected, it is divided into two
     segments at a clip edge, so that one segment
     can be trivially rejected.
     These three steps are performed iteratively
     until what remains can be trivially accepted or
     rejected.
Cohen-Sutherland Algorithm


                   1001                1000   1010


bit 0 : y > ymax                                     bit 2 : x > xmax
                   0001                0000   0010
bit 1 : y < ymin                                     bit 3 : x < xmin


                   0101                0100   0110
                                clip
                          rectangle


                   Region outcodes
Cohen-Sutherland Algorithm
1. A line segment can be trivially
   accepted if the outcodes of both the
   endpoints are zero.
2. A line segment can be trivially
   rejected if the logical AND of the
   outcodes of the endpoints is not zero.
3. A key property of the outcode is that
   bits that are set in nonzero outcode
   correspond to edges crossed.
Cohen-Sutherland Algorithm

                                  E




                              D

         clip             C
   rectangle



                      B
                  A




                An Example
Cohen-Sutherland Algorithm

                                 E




                             D

         clip           C
   rectangle



                    B




                An Example
Cohen-Sutherland Algorithm



                             D

         clip           C
   rectangle



                    B




                An Example
Cohen-Sutherland Algorithm




         clip           C
   rectangle



                    B




                An Example
Parametric Line-Clipping
(1) This fundamentally different (from Cohen-
  Sutherland algorithm) and generally more
  efficient algorithm was originally published by
  Cyrus and Beck.
(2) Liang and Barsky later independently
  developed a more efficient algorithm that is
  especially fast in the special cases of upright
  2D and 3D clipping regions.They also
  introduced more efficient trivial rejection tests
  for general clip regions.
The Cyrus-Back Algorithm
Outside of clip region                      Inside of clip rectangle
                                            Edge Ei                                             Line P0 P : P( t ) = P0 + ( P − P0 )t
                                                                                                         1                   1
                                      PEi



                                                                                                    [                      ]
                                                      Pi ( t ) − PEi

                                                                        P1                      N i ⋅ P( t ) − PEi = 0

                                                  [
                                            N i ⋅ P( t ) − PEi = 0]
                                                                             [         ]
                                                                       N i ⋅ P( t ) − PEi < 0
                                                                                                      [                    ]
                                                                                                ⇒ N i ⋅ P0 + ( P1 − P0 ) t − PEi = 0
                                                                                                ⇒ N ⋅ [ P + ( P − P )t − P ] = 0
                   P0

                   [         ]
             N i ⋅ P( t ) − PEi > 0                                                                     i      0           1    0   Ei

                                 Ni                                                                    N ⋅ [P − P ]
                                                                                                               i       0       Ei
                                                                                                ⇒t=
                                                                                                            − N i ⋅ ( P0 − P1 )

                                                                                                ⇒t=
                                                                                                                   [
                                                                                                            N i ⋅ P0 − PEi      ], D= P −P
                                                                                                                                         0   1
                                                                                                               − Ni ⋅ D
The Cyrus-Back Algorithm
    Outside of clip region                      Inside of clip rectangle
                                                Edge Ei
                                          PEi

                                                          Pi ( t ) − PEi

                                                                            P1


                                                                                 [         ]
                                                                           N i ⋅ P( t ) − PEi < 0

                       P0
                                                      [
                                                N i ⋅ P( t ) − PEi = 0]
                       [         ]
                 N i ⋅ P( t ) − PEi > 0


                                     Ni



                                                                    t exists when

    t=
                           [
              N i ⋅ P0 − PEi               ]                        (1) N i ≠ 0
                     − Ni ⋅ D                                       ( 2)             D ≠ 0 ⇒ P0 ≠ P1
                                                                    ( 3)             Ni ⋅ D ≠ 0
The Cyrus-Back Algorithm
                                                            P   1
                                                                       t =1



                                                PE                    Line 1                              P   1
                   Line 2                                                                                         t =1
                                                                          P    1
                                                                                   t =1
                                                     PL
                            PL                                                              PL
                                                                                    PL
P   0
                                                PE
        t =0                                                                                     Line 3
                                 P   0
                                         t =0

                                                PE

                                          PE
         P     0
                    t =0                                  Clip
                                                          rectangle

PE = Potentially Entering                                                           PL = Potentially Leaving
        N i ⋅ D < 0 ⇒ PE                                                                  N i ⋅ D > 0 ⇒ PL
        ⇒ Angle > 90°                                                                     ⇒ Angle < 90°
The Cyrus-Back Algorithm
Precalculate Ni and PEi for each edge
for (each line segment to be clipped) {
   if (P1 == P0)
         line is degenerated, so clip as a point;
   else {
         tE = 0; tL = 1;
         for (each candidate intersection with a clip edge) {
                    if (Ni • D != 0) { /* Ignore edges parallel to line */
                              calculate t;
                              use sign of Ni • D to categorize as PE or PL;
                              if (PE) tE = max(tE , t);
                              if (PL) tL = min(tL , t);
                    }
         }
         if (tE > tL) return NULL;
         else return P(tE) and P(tL) as true clip intersection;
   }
}
Polygon Clipping




          Example
Polygon Clipping




         Example
Polygon Clipping




         Example
Sutherland-Hodgeman Algo.




Clip ClipAgainst BottomClipping
    Clip The Clipped Polygon
     Against Left Right Clipping
          Against Clipping Boundary
             Top
           Initial Condition
              Boundary
4 Cases of Polygon Clipping
                       Inside           Outside
                                        i :first output
                                                          p
                                                          s
         p :second output
                      s
     Polygon
     being
     clipped



                                                          p
                                                          s

                      s :output
                      p                     (no output)
                                  Clip i :output
                                  boundary




                         2
                    Case 1
                         4
                         3
Algorithm
                                              Input vertex P                     Close Polygon entry




                                                                                              Does SF
                                  No              First Point        Yes                 intersect E?


                                                                                                  Yes


                                                                                             Compute
                                                                           F=P          Intersection I
                                                                                                         No
        Does SP intersect
                                                                No
                        E?

                                                                                              Output
                        Yes
                                                                                              vertex I

                   Compute
         Intersection Point
                              I
                                                                                                  Exit

                    Output
                    vertex I




                                               S=P




                                        Is S on left
                                  Yes
                                         side of E?


                       Output
                      vertex S

                                                 NO




                                                Exit
3D Clipping
• Both the Cohen-Sutherland and Cyrus-Beck clipping algorithm
  readily extend to 3D.
• For Cohen-Sutherland algorithm use two extra-bit in outcode for
  incorporating z < zmin and z > zmax regions
Thank You

More Related Content

What's hot

Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)
RohitK71
 
Cohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping AlgorithmCohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping Algorithm
Maruf Abdullah (Rion)
 
Curve and text clipping
Curve and text clippingCurve and text clipping
Curve and text clipping
Arvind Kumar
 
Concept of basic illumination model
Concept of basic illumination modelConcept of basic illumination model
Concept of basic illumination model
Ankit Garg
 
Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clipping
Mani Kanth
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clippingMohd Arif
 
Clipping in Computer Graphics
Clipping in Computer Graphics Clipping in Computer Graphics
Clipping in Computer Graphics
Barani Tharan
 
Visible surface identification
Visible surface identificationVisible surface identification
Visible surface identification
Pooja Dixit
 
Clipping Algorithm In Computer Graphics
Clipping Algorithm In Computer GraphicsClipping Algorithm In Computer Graphics
Clipping Algorithm In Computer Graphicsstudent(MCA)
 
3D Display Method
3D Display Method3D Display Method
3D Display Method
Khaled Sany
 
Polygon filling
Polygon fillingPolygon filling
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processing
Ahmed Daoud
 
Bezier Curve in Computer Graphics.docx
Bezier Curve in Computer Graphics.docxBezier Curve in Computer Graphics.docx
Bezier Curve in Computer Graphics.docx
bcanawakadalcollege
 
Liang barsky Line Clipping Algorithm
Liang barsky Line Clipping AlgorithmLiang barsky Line Clipping Algorithm
Liang barsky Line Clipping Algorithm
Arvind Kumar
 
B. SC CSIT Computer Graphics Unit 3 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 3 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 3 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 3 By Tekendra Nath Yogi
Tekendra Nath Yogi
 
Windowing clipping
Windowing   clippingWindowing   clipping
Windowing clipping
Shweta Shah
 
Edge Detection and Segmentation
Edge Detection and SegmentationEdge Detection and Segmentation
Edge Detection and Segmentation
A B Shinde
 
Introduction to the curves
Introduction to the curvesIntroduction to the curves
Introduction to the curves
Arti Parab Academics
 
Bezier and Spline Curves and Surfaces
Bezier and Spline Curves and SurfacesBezier and Spline Curves and Surfaces
Bezier and Spline Curves and Surfaces
Syed Zaid Irshad
 

What's hot (20)

Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)
 
Cohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping AlgorithmCohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping Algorithm
 
Curve and text clipping
Curve and text clippingCurve and text clipping
Curve and text clipping
 
Concept of basic illumination model
Concept of basic illumination modelConcept of basic illumination model
Concept of basic illumination model
 
Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clipping
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Clipping in Computer Graphics
Clipping in Computer Graphics Clipping in Computer Graphics
Clipping in Computer Graphics
 
Visible surface identification
Visible surface identificationVisible surface identification
Visible surface identification
 
Clipping Algorithm In Computer Graphics
Clipping Algorithm In Computer GraphicsClipping Algorithm In Computer Graphics
Clipping Algorithm In Computer Graphics
 
3D Display Method
3D Display Method3D Display Method
3D Display Method
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processing
 
Bezier Curve in Computer Graphics.docx
Bezier Curve in Computer Graphics.docxBezier Curve in Computer Graphics.docx
Bezier Curve in Computer Graphics.docx
 
Liang barsky Line Clipping Algorithm
Liang barsky Line Clipping AlgorithmLiang barsky Line Clipping Algorithm
Liang barsky Line Clipping Algorithm
 
B. SC CSIT Computer Graphics Unit 3 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 3 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 3 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 3 By Tekendra Nath Yogi
 
Windowing clipping
Windowing   clippingWindowing   clipping
Windowing clipping
 
Edge Detection and Segmentation
Edge Detection and SegmentationEdge Detection and Segmentation
Edge Detection and Segmentation
 
Clipping
ClippingClipping
Clipping
 
Introduction to the curves
Introduction to the curvesIntroduction to the curves
Introduction to the curves
 
Bezier and Spline Curves and Surfaces
Bezier and Spline Curves and SurfacesBezier and Spline Curves and Surfaces
Bezier and Spline Curves and Surfaces
 

Viewers also liked

2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)
Amit Kapoor
 
Notes 2D-Transformation Unit 2 Computer graphics
Notes 2D-Transformation Unit 2 Computer graphicsNotes 2D-Transformation Unit 2 Computer graphics
Notes 2D-Transformation Unit 2 Computer graphics
NANDINI SHARMA
 
Cohen-sutherland & liang-basky line clipping algorithm
Cohen-sutherland & liang-basky line clipping algorithmCohen-sutherland & liang-basky line clipping algorithm
Cohen-sutherland & liang-basky line clipping algorithm
Shilpa Hait
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
Vikas Sharma
 
Lecture 2d point,curve,text,line clipping
Lecture   2d point,curve,text,line clippingLecture   2d point,curve,text,line clipping
Lecture 2d point,curve,text,line clippingavelraj
 
Computer Graphics Notes (B.Tech, KUK, MDU)
Computer Graphics Notes (B.Tech, KUK, MDU)Computer Graphics Notes (B.Tech, KUK, MDU)
Computer Graphics Notes (B.Tech, KUK, MDU)
Rajesh Kamboj
 
Two dimensional geometric transformations
Two dimensional geometric transformationsTwo dimensional geometric transformations
Two dimensional geometric transformationsMohammad Sadiq
 
2 d geometric transformations
2 d geometric transformations2 d geometric transformations
2 d geometric transformationsMohd Arif
 
10CSL67 CG LAB PROGRAM 2
 10CSL67 CG LAB PROGRAM 2 10CSL67 CG LAB PROGRAM 2
10CSL67 CG LAB PROGRAM 2
Vanishree Arun
 
A Polynomial-Space Exact Algorithm for TSP in Degree-5 Graphs
A Polynomial-Space Exact Algorithm for TSP in Degree-5 GraphsA Polynomial-Space Exact Algorithm for TSP in Degree-5 Graphs
A Polynomial-Space Exact Algorithm for TSP in Degree-5 Graphs
京都大学大学院情報学研究科数理工学専攻
 
Artificial neural network for misuse detection
Artificial neural network for misuse detectionArtificial neural network for misuse detection
Artificial neural network for misuse detectionLikan Patra
 
Homogeneous representation
Homogeneous representationHomogeneous representation
Homogeneous representation
gosaliya dheirya
 
Computer graphics
Computer graphicsComputer graphics
Computer graphicsamitsarda3
 
Cohen and Sutherland Algorithm for 7-8 marks
Cohen and Sutherland Algorithm for 7-8 marksCohen and Sutherland Algorithm for 7-8 marks
Cohen and Sutherland Algorithm for 7-8 marks
Rehan Khan
 
Supot37255412160
Supot37255412160Supot37255412160
Supot37255412160Ajay Ochani
 
Source-to-Source Compiler
Source-to-Source CompilerSource-to-Source Compiler
Source-to-Source CompilerMintoo Jakhmola
 
Neural Network Classification and its Applications in Insurance Industry
Neural Network Classification and its Applications in Insurance IndustryNeural Network Classification and its Applications in Insurance Industry
Neural Network Classification and its Applications in Insurance IndustryInderjeet Singh
 

Viewers also liked (20)

2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)
 
Notes 2D-Transformation Unit 2 Computer graphics
Notes 2D-Transformation Unit 2 Computer graphicsNotes 2D-Transformation Unit 2 Computer graphics
Notes 2D-Transformation Unit 2 Computer graphics
 
Cohen-sutherland & liang-basky line clipping algorithm
Cohen-sutherland & liang-basky line clipping algorithmCohen-sutherland & liang-basky line clipping algorithm
Cohen-sutherland & liang-basky line clipping algorithm
 
Curve clipping
Curve clippingCurve clipping
Curve clipping
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Lecture 2d point,curve,text,line clipping
Lecture   2d point,curve,text,line clippingLecture   2d point,curve,text,line clipping
Lecture 2d point,curve,text,line clipping
 
Computer Graphics Notes (B.Tech, KUK, MDU)
Computer Graphics Notes (B.Tech, KUK, MDU)Computer Graphics Notes (B.Tech, KUK, MDU)
Computer Graphics Notes (B.Tech, KUK, MDU)
 
Two dimensional geometric transformations
Two dimensional geometric transformationsTwo dimensional geometric transformations
Two dimensional geometric transformations
 
2 d geometric transformations
2 d geometric transformations2 d geometric transformations
2 d geometric transformations
 
10CSL67 CG LAB PROGRAM 2
 10CSL67 CG LAB PROGRAM 2 10CSL67 CG LAB PROGRAM 2
10CSL67 CG LAB PROGRAM 2
 
Neural networks
Neural networksNeural networks
Neural networks
 
06 clipping
06 clipping06 clipping
06 clipping
 
A Polynomial-Space Exact Algorithm for TSP in Degree-5 Graphs
A Polynomial-Space Exact Algorithm for TSP in Degree-5 GraphsA Polynomial-Space Exact Algorithm for TSP in Degree-5 Graphs
A Polynomial-Space Exact Algorithm for TSP in Degree-5 Graphs
 
Artificial neural network for misuse detection
Artificial neural network for misuse detectionArtificial neural network for misuse detection
Artificial neural network for misuse detection
 
Homogeneous representation
Homogeneous representationHomogeneous representation
Homogeneous representation
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Cohen and Sutherland Algorithm for 7-8 marks
Cohen and Sutherland Algorithm for 7-8 marksCohen and Sutherland Algorithm for 7-8 marks
Cohen and Sutherland Algorithm for 7-8 marks
 
Supot37255412160
Supot37255412160Supot37255412160
Supot37255412160
 
Source-to-Source Compiler
Source-to-Source CompilerSource-to-Source Compiler
Source-to-Source Compiler
 
Neural Network Classification and its Applications in Insurance Industry
Neural Network Classification and its Applications in Insurance IndustryNeural Network Classification and its Applications in Insurance Industry
Neural Network Classification and its Applications in Insurance Industry
 

Similar to 06 clipping

Week6.ppt
Week6.pptWeek6.ppt
Week6.ppt
RUHULAMINLASKAR2
 
Line clipping
Line clippingLine clipping
Line clipping
Ankit Garg
 
7th Math (C2) - L61--March30
7th Math (C2) - L61--March307th Math (C2) - L61--March30
7th Math (C2) - L61--March30jdurst65
 
All in one page trigo
All in one page trigoAll in one page trigo
All in one page trigozabidah awang
 
MATHEON Center Days: Index determination and structural analysis using Algori...
MATHEON Center Days: Index determination and structural analysis using Algori...MATHEON Center Days: Index determination and structural analysis using Algori...
MATHEON Center Days: Index determination and structural analysis using Algori...
Dagmar Monett
 
51955900 form-4-chapter-5
51955900 form-4-chapter-551955900 form-4-chapter-5
51955900 form-4-chapter-5Ragulan Dev
 
11 x1 t13 07 products of intercepts (2012)
11 x1 t13 07 products of intercepts (2012)11 x1 t13 07 products of intercepts (2012)
11 x1 t13 07 products of intercepts (2012)Nigel Simmons
 
11X1 T13 07 products of intercepts (2010)
11X1 T13 07 products of intercepts (2010)11X1 T13 07 products of intercepts (2010)
11X1 T13 07 products of intercepts (2010)Nigel Simmons
 
11X1 T13 07 products of intercepts (2011)
11X1 T13 07 products of intercepts (2011)11X1 T13 07 products of intercepts (2011)
11X1 T13 07 products of intercepts (2011)Nigel Simmons
 
Trig overview
Trig overviewTrig overview
Trig overview
'Xgen Zeepee
 
Lecture 02
Lecture 02Lecture 02
Lecture 02
Lucian Nicolau
 
Lucanas Presentation R Rver2 Dcm2
Lucanas Presentation R Rver2 Dcm2Lucanas Presentation R Rver2 Dcm2
Lucanas Presentation R Rver2 Dcm2mdlynch
 
Lecture6
Lecture6Lecture6
Lecture6voracle
 
Mathematics Keynotes 2
Mathematics Keynotes 2Mathematics Keynotes 2
Mathematics Keynotes 2guestcc333c
 
Applied Math 40S May 26, 2008
Applied Math 40S May 26, 2008Applied Math 40S May 26, 2008
Applied Math 40S May 26, 2008
Darren Kuropatwa
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data StructureAnuj Modi
 

Similar to 06 clipping (20)

Week6.ppt
Week6.pptWeek6.ppt
Week6.ppt
 
Line clipping
Line clippingLine clipping
Line clipping
 
JMM Mini4- Sydney Opera House Part 2
JMM Mini4- Sydney Opera House Part 2JMM Mini4- Sydney Opera House Part 2
JMM Mini4- Sydney Opera House Part 2
 
7th Math (C2) - L61--March30
7th Math (C2) - L61--March307th Math (C2) - L61--March30
7th Math (C2) - L61--March30
 
All in one page trigo
All in one page trigoAll in one page trigo
All in one page trigo
 
Em03 t
Em03 tEm03 t
Em03 t
 
MATHEON Center Days: Index determination and structural analysis using Algori...
MATHEON Center Days: Index determination and structural analysis using Algori...MATHEON Center Days: Index determination and structural analysis using Algori...
MATHEON Center Days: Index determination and structural analysis using Algori...
 
51955900 form-4-chapter-5
51955900 form-4-chapter-551955900 form-4-chapter-5
51955900 form-4-chapter-5
 
11 x1 t13 07 products of intercepts (2012)
11 x1 t13 07 products of intercepts (2012)11 x1 t13 07 products of intercepts (2012)
11 x1 t13 07 products of intercepts (2012)
 
11X1 T13 07 products of intercepts (2010)
11X1 T13 07 products of intercepts (2010)11X1 T13 07 products of intercepts (2010)
11X1 T13 07 products of intercepts (2010)
 
11X1 T13 07 products of intercepts (2011)
11X1 T13 07 products of intercepts (2011)11X1 T13 07 products of intercepts (2011)
11X1 T13 07 products of intercepts (2011)
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Trig overview
Trig overviewTrig overview
Trig overview
 
Lecture 02
Lecture 02Lecture 02
Lecture 02
 
Lucanas Presentation R Rver2 Dcm2
Lucanas Presentation R Rver2 Dcm2Lucanas Presentation R Rver2 Dcm2
Lucanas Presentation R Rver2 Dcm2
 
Lecture6
Lecture6Lecture6
Lecture6
 
Mathematics Keynotes 2
Mathematics Keynotes 2Mathematics Keynotes 2
Mathematics Keynotes 2
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Applied Math 40S May 26, 2008
Applied Math 40S May 26, 2008Applied Math 40S May 26, 2008
Applied Math 40S May 26, 2008
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data Structure
 

Recently uploaded

Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 

Recently uploaded (20)

Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 

06 clipping

  • 1. CSE 423 Computer Graphics Clipping • Cohen Sutherland Algorithm (Line) • Cyrus-Back Algorithm (Line) • Sutherland-Hodgeman Algorithm (Polygon) • Cohen Sutherland Algorithm (3d)
  • 2. Point Clipping clip rectangle y = y max ( x max , y max ) x = x min x = x max ( x min , y min ) y = y min For a point (x,y) to be inside the clip rectangle: xmin ≤ x ≤ xmax ymin ≤ y ≤ ymax
  • 3. Point Clipping clip rectangle y = y max ( x max , y max ) (x 1, y 1) x = x min x = x max ( x min , y min ) y = y min For a point (x,y) to be inside the clip rectangle: xmin ≤ x ≤ xmax ymin ≤ y ≤ ymax
  • 4. Line Clipping clip rectangle Cases for clipping lines
  • 5. Line Clipping B B A A clip rectangle Cases for clipping lines
  • 6. Line Clipping D D' D' C C B B A A clip rectangle Cases for clipping lines
  • 7. Line Clipping F D D' D' C C B B E A A clip rectangle Cases for clipping lines
  • 8. Line Clipping F D D' D' C C B H B E H' H' A A G' G' clip G rectangle Cases for clipping lines
  • 9. Line Clipping F D D' D' C C B H B E H' J H' A A G' G' J' clip G rectangle I' I Cases for clipping lines
  • 10. Line Clipping Clipping Lines by Solving Simultaneous Equations (x 1, y 1) (x 1, y 1) (x , y ) (x b, y b) (x a, y a) (x b , y b) (x , y ) (x a, y a) (x 0, y 0) (x 0, y 0) (x c, y c) (x d, y d) (x c, y c) (x d , y d) clip clip rectangle rectangle x = x0 +tline ( x1 − x0 ), y = y0 +tline ( y1 − y0 ) x = xa +t edge ( xb − xa ), y = ya +t edge ( yb − y a )
  • 11. Cohen-Sutherland Algorithm The Cohen-Sutherland Line-Clipping Algorithm performs initial tests on a line to determine whether intersection calculations can be avoided. 1. First, end-point pairs are checked for Trivial Acceptance. 2. If the line cannot be trivially accepted, region checks are done for Trivial Rejection. 3. If the line segment can be neither trivially accepted or rejected, it is divided into two segments at a clip edge, so that one segment can be trivially rejected. These three steps are performed iteratively until what remains can be trivially accepted or rejected.
  • 12. Cohen-Sutherland Algorithm 1001 1000 1010 bit 0 : y > ymax bit 2 : x > xmax 0001 0000 0010 bit 1 : y < ymin bit 3 : x < xmin 0101 0100 0110 clip rectangle Region outcodes
  • 13. Cohen-Sutherland Algorithm 1. A line segment can be trivially accepted if the outcodes of both the endpoints are zero. 2. A line segment can be trivially rejected if the logical AND of the outcodes of the endpoints is not zero. 3. A key property of the outcode is that bits that are set in nonzero outcode correspond to edges crossed.
  • 14. Cohen-Sutherland Algorithm E D clip C rectangle B A An Example
  • 15. Cohen-Sutherland Algorithm E D clip C rectangle B An Example
  • 16. Cohen-Sutherland Algorithm D clip C rectangle B An Example
  • 17. Cohen-Sutherland Algorithm clip C rectangle B An Example
  • 18. Parametric Line-Clipping (1) This fundamentally different (from Cohen- Sutherland algorithm) and generally more efficient algorithm was originally published by Cyrus and Beck. (2) Liang and Barsky later independently developed a more efficient algorithm that is especially fast in the special cases of upright 2D and 3D clipping regions.They also introduced more efficient trivial rejection tests for general clip regions.
  • 19. The Cyrus-Back Algorithm Outside of clip region Inside of clip rectangle Edge Ei Line P0 P : P( t ) = P0 + ( P − P0 )t 1 1 PEi [ ] Pi ( t ) − PEi P1 N i ⋅ P( t ) − PEi = 0 [ N i ⋅ P( t ) − PEi = 0] [ ] N i ⋅ P( t ) − PEi < 0 [ ] ⇒ N i ⋅ P0 + ( P1 − P0 ) t − PEi = 0 ⇒ N ⋅ [ P + ( P − P )t − P ] = 0 P0 [ ] N i ⋅ P( t ) − PEi > 0 i 0 1 0 Ei Ni N ⋅ [P − P ] i 0 Ei ⇒t= − N i ⋅ ( P0 − P1 ) ⇒t= [ N i ⋅ P0 − PEi ], D= P −P 0 1 − Ni ⋅ D
  • 20. The Cyrus-Back Algorithm Outside of clip region Inside of clip rectangle Edge Ei PEi Pi ( t ) − PEi P1 [ ] N i ⋅ P( t ) − PEi < 0 P0 [ N i ⋅ P( t ) − PEi = 0] [ ] N i ⋅ P( t ) − PEi > 0 Ni t exists when t= [ N i ⋅ P0 − PEi ] (1) N i ≠ 0 − Ni ⋅ D ( 2) D ≠ 0 ⇒ P0 ≠ P1 ( 3) Ni ⋅ D ≠ 0
  • 21. The Cyrus-Back Algorithm P 1 t =1 PE Line 1 P 1 Line 2 t =1 P 1 t =1 PL PL PL PL P 0 PE t =0 Line 3 P 0 t =0 PE PE P 0 t =0 Clip rectangle PE = Potentially Entering PL = Potentially Leaving N i ⋅ D < 0 ⇒ PE N i ⋅ D > 0 ⇒ PL ⇒ Angle > 90° ⇒ Angle < 90°
  • 22. The Cyrus-Back Algorithm Precalculate Ni and PEi for each edge for (each line segment to be clipped) { if (P1 == P0) line is degenerated, so clip as a point; else { tE = 0; tL = 1; for (each candidate intersection with a clip edge) { if (Ni • D != 0) { /* Ignore edges parallel to line */ calculate t; use sign of Ni • D to categorize as PE or PL; if (PE) tE = max(tE , t); if (PL) tL = min(tL , t); } } if (tE > tL) return NULL; else return P(tE) and P(tL) as true clip intersection; } }
  • 23. Polygon Clipping Example
  • 24. Polygon Clipping Example
  • 25. Polygon Clipping Example
  • 26. Sutherland-Hodgeman Algo. Clip ClipAgainst BottomClipping Clip The Clipped Polygon Against Left Right Clipping Against Clipping Boundary Top Initial Condition Boundary
  • 27. 4 Cases of Polygon Clipping Inside Outside i :first output p s p :second output s Polygon being clipped p s s :output p (no output) Clip i :output boundary 2 Case 1 4 3
  • 28. Algorithm Input vertex P Close Polygon entry Does SF No First Point Yes intersect E? Yes Compute F=P Intersection I No Does SP intersect No E? Output Yes vertex I Compute Intersection Point I Exit Output vertex I S=P Is S on left Yes side of E? Output vertex S NO Exit
  • 29. 3D Clipping • Both the Cohen-Sutherland and Cyrus-Beck clipping algorithm readily extend to 3D. • For Cohen-Sutherland algorithm use two extra-bit in outcode for incorporating z < zmin and z > zmax regions