SlideShare a Scribd company logo
2D Viewing 고려대학교 컴퓨터 그래픽스 연구실
Contents 3D Rendering Pipeline 2D Rendering Pipeline Clipping Cohen-Sutherland Line Clipping Sutherland-Hodgeman Polygon Clipping Viewport Transformation Scan Conversion Summary of Transformation
3D Rendering Pipeline Model Transformation Lighting Viewing Transformation Projection Transformation Clipping Viewport Transformation Scan Conversion 3D Primitives Image 3D Modeling Coordinates 3D World Coordinates 3D World Coordinates 3D Viewing Coordinates 2D Projection Coordinates 2D Projection Coordinates 2D Device Coordinates 2D Device Coordinates
3D Rendering Pipeline Model Transformation Lighting Viewing Transformation Projection Transformation Clipping Viewport Transformation Scan Conversion 3D Primitives Image 3D Modeling Coordinates 3D World Coordinates 3D World Coordinates 3D Viewing Coordinates 2D Projection Coordinates 2D Projection Coordinates 2D Device Coordinates 2D Device Coordinates
2D Rendering Pipeline 3D Primitives Clipping Viewport Transformation Scan Conversion Image Clip portions of geometric primitives  residing outside window Transform the clipped primitives  from screen to image coordinates Fill pixel representing primitives  in screen coordinates 2D Primitives
2D Rendering Pipeline 3D Primitives Clipping Viewport Transformation Scan Conversion Image Clip portions of geometric primitives  residing outside window Transform the clipped primitives  from screen to image coordinates Fill pixel representing primitives  in screen coordinates 2D Primitives
Clipping Avoid Drawing Parts of Primitives Outside Window Window defines part of scene being viewed Must draw geometric primitives only inside window  World Coordinates
Clipping Avoid Drawing Parts of Primitives Outside Window Window defines part of scene being viewed Must draw geometric primitives only inside window
Clipping Avoid Drawing Parts of Primitives Outside Window Points Lines Polygons Circles etc.
Point Clipping  Is Point(x,y) Inside the Clip Window? (x, y) wx2 wx1 wy1 wy2 Inside = (x>=wx1) && (x<=wx2) && (y>=wy1) && (y<=wy2);
Line Clipping Find the Part of a Line Inside the Clip Window  P 7 P 8 P 10 P 9 P 1 P 2 P 5 P 4 P 3 P 6 Before Clipping
Line Clipping Find the Part of a Line Inside the Clip Window  After Clipping P 4 P 3 P 6 P’ 8 P’ 7 P’ 5
Cohen-Sutherland Line Clipping Use Simple Tests to Classify Easy Cases First P 7 P 8 P 10 P 9 P 1 P 2 P 5 P 4 P 3 P 6
Cohen-Sutherland Line Clipping Classify Some Lines Quickly by AND of Bit Codes Representing Regions of Two Endpoints (Must Be 0) P 10 P 5 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 P 1 P 2 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1
Cohen-Sutherland Line Clipping Classify Some Lines Quickly by AND of Bit Codes Representing Regions of Two Endpoints (Must Be 0) P 10 P 5 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 P 1 P 2 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1
Cohen-Sutherland Line Clipping Classify Some Lines Quickly by AND of Bit Codes Representing Regions of Two Endpoints (Must Be 0) P 10 P 5 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1
Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 5 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1
Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 5 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1
Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5
Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5
Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5
Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5
Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7
Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7
Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7 P’ 8
Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7 P’ 8
Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7 P’ 8
Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7 P’ 8
Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 0001 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7 P’ 8 P’ 9
Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 6 0001 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7 P’ 8 P 10 P’ 9
Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 6 0001 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7 P’ 8
Polygon Clipping Find the Part of a Polygon Inside the Clip Window? Before Clipping
Polygon Clipping Find the Part of a Polygon Inside the Clip Window? After Clipping
Sutherland-Hodgeman Polygon Clipping Clip to Each Window Boundary One at a Time
Sutherland-Hodgeman Polygon Clipping Clip to Each Window Boundary One at a Time
Sutherland-Hodgeman Polygon Clipping Clip to Each Window Boundary One at a Time
Sutherland-Hodgeman Polygon Clipping Clip to Each Window Boundary One at a Time
Sutherland-Hodgeman Polygon Clipping Clip to Each Window Boundary One at a Time
Clipping to a Boundary Do Inside Test for Each Point in Sequence,  Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 P 3 P 4 P 5 Inside Outside Window  Boundary
Clipping to a Boundary Do Inside Test for Each Point in Sequence,  Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 P 3 P 4 P 5 Inside Outside Window  Boundary
Clipping to a Boundary Do Inside Test for Each Point in Sequence,  Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 P 3 P 4 P 5 Inside Outside Window  Boundary
Clipping to a Boundary Do Inside Test for Each Point in Sequence,  Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 P 3 P 4 P 5 Inside Outside Window  Boundary
Clipping to a Boundary Do Inside Test for Each Point in Sequence,  Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 P 3 P 4 P 5 Inside Outside Window  Boundary P’
Clipping to a Boundary Do Inside Test for Each Point in Sequence,  Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 P 3 P 4 P 5 Inside Outside Window  Boundary P’
Clipping to a Boundary Do Inside Test for Each Point in Sequence,  Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 P 3 P 4 P 5 Inside Outside Window  Boundary P’
Clipping to a Boundary Do Inside Test for Each Point in Sequence,  Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 P 3 P 4 P 5 Inside Outside Window  Boundary P’ P”
Clipping to a Boundary Do Inside Test for Each Point in Sequence,  Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 Inside Outside Window  Boundary P’ P”
2D Rendering Pipeline 3D Primitives Clipping Viewport Transformation Scan Conversion Image Clip portions of geometric primitives  residing outside window Transform the clipped primitives  from screen to image coordinates Fill pixel representing primitives  in screen coordinates 2D Primitives
Viewport Transformation Transform 2D Geometric Primitives from  Screen Coordinate System (Projection Coordinates)  to  Image Coordinate System (Device Coordinates) Screen Image Viewport
Window vs. Viewport Window World-coordinate area selected for display What is to be viewed Viewport Area on the display device to which a window is mapped Where it is to be displayed
Viewport Transformation Window-to-Viewport Mapping (wx, wy) wx2 wx1 wy1 wy2 (vx, vy) vx2 vx1 vy1 vy2 Window Viewport Screen Coordinates Image Coordinates vx = vx1 + (wx – wx1) * (vx2 – vx1) / (wx2 – wx1); vy = vy1 + (wy – wy1) * (vy2 – vy1) / (wy2 – wy1);
2D Rendering Pipeline 3D Primitives Clipping Viewport Transformation Scan Conversion Image Clip portions of geometric primitives  residing outside window Transform the clipped primitives  from screen to image coordinates Fill pixel representing primitives  in screen coordinates 2D Primitives
Scan Conversion Definition Figure out which pixels to fill Example Filling the inside of a triangle P 1 P 2 P 3
Triangle Scan Conversion Simple Algorithm Color all pixels inside a triangle Inside triangle test A point is inside a triangle if it is in the positive halfspace of all three boundary lines L 1 L 2 L 3 P
Triangle Scan Conversion Triangle Sweep-Line Algorithm Take advantage of spatial coherence Compute which pixels are inside using horizontal spans Process horizontal spans in scan-line order Take advantage of edge linearity Use edge slopes to update coordinates incrementally dx dy
Polygon Scan Conversion Fill Pixels Inside a Polygon Triangle Quadrilateral Convex Star-Shaped Concave Self-Intersecting Holes
Inside Polygon Rule Need Better Test for Points Inside a Polygon “ Inside triangle test” works only for convex polygon Convex Polygon Concave Polygon L 1 L 2 L 3 L 4 L 5 L 1 L 2 L 3 L 4 L 5A L 5B
Inside Polygon Rule Odd-Parity Rule Any ray from P to infinity crosses odd number of edges Concave Self-Intersecting With Holes
Polygon Scan Conversion Polygon Line-Sweep Algorithm Incremental algorithm to find spans, and determine insideness with odd-parity rule Triangle Polygon
Polygon Scan Conversion Hardware Scan Conversion Convert everything into Triangles
Summary of Transformation P(x, y, z) Viewing  Transformation Projection  Transformation Window-to-Viewport  Transformation P(x, y) Modeling  Transformation 3D Object Coordinates 3D World Coordinates 3D Viewing Coordinates 2D Projection Coordinates 2D Device Coordinates

More Related Content

PPTX
Lect 5 2d clipping
PPT
Clipping2
PPTX
Clipping in Computer Graphics
PPT
Clipping
PPT
Clipping
PPTX
Clipping computer graphics
PPT
06 clipping
PPT
Polygon clipping
Lect 5 2d clipping
Clipping2
Clipping in Computer Graphics
Clipping
Clipping
Clipping computer graphics
06 clipping
Polygon clipping

What's hot (20)

PPTX
Bhavesh window clipping slidshare
PDF
Comparison of Various Line Clipping Algorithm for Improvement
PPT
Lecture 2d point,curve,text,line clipping
PPTX
Clipping in 2 d
PPT
Polygon clipping
PPT
Line clipping
PPTX
Clipping 22
PPT
Clipping in Computer Graphics
PPTX
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
PPTX
Clipping ( Cohen-Sutherland Algorithm )
PPT
Polygon clipping
PPTX
Clipping
PPTX
2D viewing & clipping
PPTX
Cohen sutherland line clipping
PPTX
Circle & curve clipping algorithm
PPTX
Computer Graphic - Clipping
PPTX
Cohen-Sutherland Line Clipping Algorithm
PDF
clipping
PPTX
Curve clipping
Bhavesh window clipping slidshare
Comparison of Various Line Clipping Algorithm for Improvement
Lecture 2d point,curve,text,line clipping
Clipping in 2 d
Polygon clipping
Line clipping
Clipping 22
Clipping in Computer Graphics
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
Clipping ( Cohen-Sutherland Algorithm )
Polygon clipping
Clipping
2D viewing & clipping
Cohen sutherland line clipping
Circle & curve clipping algorithm
Computer Graphic - Clipping
Cohen-Sutherland Line Clipping Algorithm
clipping
Curve clipping
Ad

Viewers also liked (20)

PPTX
2 d viewing computer graphics
PDF
Lect7 viewing in2d
PPT
2 d transformations by amit kumar (maimt)
PPT
Introduction to Computer Graphics(1)
PPT
Overview of graphics systems
PPTX
Computer Graphics
PPTX
Windows to viewport transformation
PPTX
Chapter 3 Output Primitives
PPTX
Viewing transformation
PPT
Windows and viewport
PPTX
Attributes of Output Primitives
PPT
Two dimensional geometric transformations
PPTX
Output primitives in Computer Graphics
PPT
Hearn and Baker 2 D transformations
PDF
Notes 2D-Transformation Unit 2 Computer graphics
PPT
Two dimensional viewing
PPTX
Database Normalization
PPT
Databases: Normalisation
PPT
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
PPT
applications of computer graphics
2 d viewing computer graphics
Lect7 viewing in2d
2 d transformations by amit kumar (maimt)
Introduction to Computer Graphics(1)
Overview of graphics systems
Computer Graphics
Windows to viewport transformation
Chapter 3 Output Primitives
Viewing transformation
Windows and viewport
Attributes of Output Primitives
Two dimensional geometric transformations
Output primitives in Computer Graphics
Hearn and Baker 2 D transformations
Notes 2D-Transformation Unit 2 Computer graphics
Two dimensional viewing
Database Normalization
Databases: Normalisation
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
applications of computer graphics
Ad

Similar to 2D viewing (20)

PPTX
2D Viewing- the window by setting a two-dimensional viewing co-ordinate syst...
PDF
Chapter4.pdf
PPT
Clipping
PDF
ingraph: Live Queries on Graphs
PPTX
Clipping 22
PDF
Incremental Graph Queries for Cypher
PPTX
ohu.pptx
PPTX
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
PDF
Materi_05_CG_2223_2_.pdf
PDF
Giuliano david bozzo moncada
PDF
Exactly Once Semantics Revisited (Jason Gustafson, Confluent) Kafka Summit NY...
PDF
M.Sc_.-IV_ComputerGraphics_PolygonClipping_Bhupendra_K_Pandya.pdf
PDF
Scheme logic implement pwr plant cntrl
DOC
Unit 4 notes
PPTX
hgfcgf.pptx
PPTX
ibuib.pptx
PPT
99995327.ppt
PPTX
ytdty.pptx
PPTX
yyfty.pptx
PPTX
kfty.pptx
2D Viewing- the window by setting a two-dimensional viewing co-ordinate syst...
Chapter4.pdf
Clipping
ingraph: Live Queries on Graphs
Clipping 22
Incremental Graph Queries for Cypher
ohu.pptx
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
Materi_05_CG_2223_2_.pdf
Giuliano david bozzo moncada
Exactly Once Semantics Revisited (Jason Gustafson, Confluent) Kafka Summit NY...
M.Sc_.-IV_ComputerGraphics_PolygonClipping_Bhupendra_K_Pandya.pdf
Scheme logic implement pwr plant cntrl
Unit 4 notes
hgfcgf.pptx
ibuib.pptx
99995327.ppt
ytdty.pptx
yyfty.pptx
kfty.pptx

More from HiteshJain007 (9)

PPT
object 3d(1)
PPT
object 3d(2)
PPT
Raster Display(1)
PPT
02mathematics
PPT
Introduction to Computer Graphics(2)
PPT
Graphics pipeline
PPT
Hidden Surfaces
PPT
transformation 3d
PPT
viewing3d pipeline
object 3d(1)
object 3d(2)
Raster Display(1)
02mathematics
Introduction to Computer Graphics(2)
Graphics pipeline
Hidden Surfaces
transformation 3d
viewing3d pipeline

Recently uploaded (20)

PDF
Complications of Minimal Access Surgery at WLH
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PPTX
master seminar digital applications in india
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Complications of Minimal Access Surgery at WLH
VCE English Exam - Section C Student Revision Booklet
Final Presentation General Medicine 03-08-2024.pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Orientation - ARALprogram of Deped to the Parents.pptx
master seminar digital applications in india
human mycosis Human fungal infections are called human mycosis..pptx
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Abdominal Access Techniques with Prof. Dr. R K Mishra
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
202450812 BayCHI UCSC-SV 20250812 v17.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Cell Structure & Organelles in detailed.
O5-L3 Freight Transport Ops (International) V1.pdf
Final Presentation General Medicine 03-08-2024.pptx
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf

2D viewing

  • 1. 2D Viewing 고려대학교 컴퓨터 그래픽스 연구실
  • 2. Contents 3D Rendering Pipeline 2D Rendering Pipeline Clipping Cohen-Sutherland Line Clipping Sutherland-Hodgeman Polygon Clipping Viewport Transformation Scan Conversion Summary of Transformation
  • 3. 3D Rendering Pipeline Model Transformation Lighting Viewing Transformation Projection Transformation Clipping Viewport Transformation Scan Conversion 3D Primitives Image 3D Modeling Coordinates 3D World Coordinates 3D World Coordinates 3D Viewing Coordinates 2D Projection Coordinates 2D Projection Coordinates 2D Device Coordinates 2D Device Coordinates
  • 4. 3D Rendering Pipeline Model Transformation Lighting Viewing Transformation Projection Transformation Clipping Viewport Transformation Scan Conversion 3D Primitives Image 3D Modeling Coordinates 3D World Coordinates 3D World Coordinates 3D Viewing Coordinates 2D Projection Coordinates 2D Projection Coordinates 2D Device Coordinates 2D Device Coordinates
  • 5. 2D Rendering Pipeline 3D Primitives Clipping Viewport Transformation Scan Conversion Image Clip portions of geometric primitives residing outside window Transform the clipped primitives from screen to image coordinates Fill pixel representing primitives in screen coordinates 2D Primitives
  • 6. 2D Rendering Pipeline 3D Primitives Clipping Viewport Transformation Scan Conversion Image Clip portions of geometric primitives residing outside window Transform the clipped primitives from screen to image coordinates Fill pixel representing primitives in screen coordinates 2D Primitives
  • 7. Clipping Avoid Drawing Parts of Primitives Outside Window Window defines part of scene being viewed Must draw geometric primitives only inside window World Coordinates
  • 8. Clipping Avoid Drawing Parts of Primitives Outside Window Window defines part of scene being viewed Must draw geometric primitives only inside window
  • 9. Clipping Avoid Drawing Parts of Primitives Outside Window Points Lines Polygons Circles etc.
  • 10. Point Clipping Is Point(x,y) Inside the Clip Window? (x, y) wx2 wx1 wy1 wy2 Inside = (x>=wx1) && (x<=wx2) && (y>=wy1) && (y<=wy2);
  • 11. Line Clipping Find the Part of a Line Inside the Clip Window P 7 P 8 P 10 P 9 P 1 P 2 P 5 P 4 P 3 P 6 Before Clipping
  • 12. Line Clipping Find the Part of a Line Inside the Clip Window After Clipping P 4 P 3 P 6 P’ 8 P’ 7 P’ 5
  • 13. Cohen-Sutherland Line Clipping Use Simple Tests to Classify Easy Cases First P 7 P 8 P 10 P 9 P 1 P 2 P 5 P 4 P 3 P 6
  • 14. Cohen-Sutherland Line Clipping Classify Some Lines Quickly by AND of Bit Codes Representing Regions of Two Endpoints (Must Be 0) P 10 P 5 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 P 1 P 2 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1
  • 15. Cohen-Sutherland Line Clipping Classify Some Lines Quickly by AND of Bit Codes Representing Regions of Two Endpoints (Must Be 0) P 10 P 5 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 P 1 P 2 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1
  • 16. Cohen-Sutherland Line Clipping Classify Some Lines Quickly by AND of Bit Codes Representing Regions of Two Endpoints (Must Be 0) P 10 P 5 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1
  • 17. Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 5 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1
  • 18. Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 5 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1
  • 19. Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5
  • 20. Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5
  • 21. Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5
  • 22. Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 P 7 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5
  • 23. Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7
  • 24. Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 P 8 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7
  • 25. Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7 P’ 8
  • 26. Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7 P’ 8
  • 27. Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7 P’ 8
  • 28. Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 P 9 0001 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7 P’ 8
  • 29. Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 10 P 6 0001 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7 P’ 8 P’ 9
  • 30. Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 6 0001 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7 P’ 8 P 10 P’ 9
  • 31. Cohen-Sutherland Line Clipping Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P 6 0001 0101 0100 0110 0010 0000 1010 1000 1001 P 4 P 3 Bit 4 Bit 3 Bit 2 Bit 1 P’ 5 P’ 7 P’ 8
  • 32. Polygon Clipping Find the Part of a Polygon Inside the Clip Window? Before Clipping
  • 33. Polygon Clipping Find the Part of a Polygon Inside the Clip Window? After Clipping
  • 34. Sutherland-Hodgeman Polygon Clipping Clip to Each Window Boundary One at a Time
  • 35. Sutherland-Hodgeman Polygon Clipping Clip to Each Window Boundary One at a Time
  • 36. Sutherland-Hodgeman Polygon Clipping Clip to Each Window Boundary One at a Time
  • 37. Sutherland-Hodgeman Polygon Clipping Clip to Each Window Boundary One at a Time
  • 38. Sutherland-Hodgeman Polygon Clipping Clip to Each Window Boundary One at a Time
  • 39. Clipping to a Boundary Do Inside Test for Each Point in Sequence, Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 P 3 P 4 P 5 Inside Outside Window Boundary
  • 40. Clipping to a Boundary Do Inside Test for Each Point in Sequence, Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 P 3 P 4 P 5 Inside Outside Window Boundary
  • 41. Clipping to a Boundary Do Inside Test for Each Point in Sequence, Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 P 3 P 4 P 5 Inside Outside Window Boundary
  • 42. Clipping to a Boundary Do Inside Test for Each Point in Sequence, Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 P 3 P 4 P 5 Inside Outside Window Boundary
  • 43. Clipping to a Boundary Do Inside Test for Each Point in Sequence, Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 P 3 P 4 P 5 Inside Outside Window Boundary P’
  • 44. Clipping to a Boundary Do Inside Test for Each Point in Sequence, Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 P 3 P 4 P 5 Inside Outside Window Boundary P’
  • 45. Clipping to a Boundary Do Inside Test for Each Point in Sequence, Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 P 3 P 4 P 5 Inside Outside Window Boundary P’
  • 46. Clipping to a Boundary Do Inside Test for Each Point in Sequence, Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 P 3 P 4 P 5 Inside Outside Window Boundary P’ P”
  • 47. Clipping to a Boundary Do Inside Test for Each Point in Sequence, Insert New Points When Cross Window Boundary, Remove Points Outside Window Boundary P 1 P 2 Inside Outside Window Boundary P’ P”
  • 48. 2D Rendering Pipeline 3D Primitives Clipping Viewport Transformation Scan Conversion Image Clip portions of geometric primitives residing outside window Transform the clipped primitives from screen to image coordinates Fill pixel representing primitives in screen coordinates 2D Primitives
  • 49. Viewport Transformation Transform 2D Geometric Primitives from Screen Coordinate System (Projection Coordinates) to Image Coordinate System (Device Coordinates) Screen Image Viewport
  • 50. Window vs. Viewport Window World-coordinate area selected for display What is to be viewed Viewport Area on the display device to which a window is mapped Where it is to be displayed
  • 51. Viewport Transformation Window-to-Viewport Mapping (wx, wy) wx2 wx1 wy1 wy2 (vx, vy) vx2 vx1 vy1 vy2 Window Viewport Screen Coordinates Image Coordinates vx = vx1 + (wx – wx1) * (vx2 – vx1) / (wx2 – wx1); vy = vy1 + (wy – wy1) * (vy2 – vy1) / (wy2 – wy1);
  • 52. 2D Rendering Pipeline 3D Primitives Clipping Viewport Transformation Scan Conversion Image Clip portions of geometric primitives residing outside window Transform the clipped primitives from screen to image coordinates Fill pixel representing primitives in screen coordinates 2D Primitives
  • 53. Scan Conversion Definition Figure out which pixels to fill Example Filling the inside of a triangle P 1 P 2 P 3
  • 54. Triangle Scan Conversion Simple Algorithm Color all pixels inside a triangle Inside triangle test A point is inside a triangle if it is in the positive halfspace of all three boundary lines L 1 L 2 L 3 P
  • 55. Triangle Scan Conversion Triangle Sweep-Line Algorithm Take advantage of spatial coherence Compute which pixels are inside using horizontal spans Process horizontal spans in scan-line order Take advantage of edge linearity Use edge slopes to update coordinates incrementally dx dy
  • 56. Polygon Scan Conversion Fill Pixels Inside a Polygon Triangle Quadrilateral Convex Star-Shaped Concave Self-Intersecting Holes
  • 57. Inside Polygon Rule Need Better Test for Points Inside a Polygon “ Inside triangle test” works only for convex polygon Convex Polygon Concave Polygon L 1 L 2 L 3 L 4 L 5 L 1 L 2 L 3 L 4 L 5A L 5B
  • 58. Inside Polygon Rule Odd-Parity Rule Any ray from P to infinity crosses odd number of edges Concave Self-Intersecting With Holes
  • 59. Polygon Scan Conversion Polygon Line-Sweep Algorithm Incremental algorithm to find spans, and determine insideness with odd-parity rule Triangle Polygon
  • 60. Polygon Scan Conversion Hardware Scan Conversion Convert everything into Triangles
  • 61. Summary of Transformation P(x, y, z) Viewing Transformation Projection Transformation Window-to-Viewport Transformation P(x, y) Modeling Transformation 3D Object Coordinates 3D World Coordinates 3D Viewing Coordinates 2D Projection Coordinates 2D Device Coordinates