1 Computer Graphics Clipping Fall FCC 2006. Line Clipping What happens when one or both endpoints of a line segment are not inside the specified drawing.

Slides:



Advertisements
Similar presentations
9.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 9 – Clipping.
Advertisements

CGPage: 1 We can define a window as a rectangular region of the world coordinate space, and the viewport as a rectangular region of the device coordinate.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Clipping Concepts, Algorithms for line clipping 1 of 16 Clipping - 10/16/12.
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 7 Scanline algorithm and polygon clipping Taku Komura.
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 30, D Clipping 1/14 Clipping (pages , )
Objectives Define Clipping Various clipping methods. Line clipping methods.
Line clipping: Line clipping algorithm is method of eliminate lines of outside area of the object,so outside of object viewing is Removed. Typically, any.
CS 551 / 645: Introductory Computer Graphics Clipping Lines and Polygons.
Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)
Course Website: Computer Graphics 4: Viewing In 2D.
Line Clipping Algorithms. A Cases for Clipping Lines E B H C G J I clip rectangle 2Prepared by Narendra V G CSE MIT.
Computer Graphics : Clipping
Computer Graphics Viewing.
Clipping CSE 403 Computer Graphics Cohen Sutherland Algorithm (Line)
Viewing & Clipping In 2D. 2 of 44 Contents Windowing Concepts Clipping –Introduction –Brute Force –Cohen-Sutherland Clipping Algorithm Area Clipping –Sutherland-Hodgman.
CGPage: 1 東吳資訊科學 江清水 The process of clipping decides which part, if any, of a primitive lies inside the window. The algorithms used for line clipping can.
CMPE 466 COMPUTER GRAPHICS Chapter 8 2D Viewing Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth Edition by Donald Hearn,
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Interpolation Clipping.
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
1 Computer Graphics Chapter 4 2D Viewing Algorithms.
1 CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai.
Computer Graphics Clipping Cohen Sutherland Algorithm (Line) Cyrus-Back Algorithm (Line) Sutherland-Hodgeman Algorithm (Polygon) Cohen Sutherland Algorithm.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Clipping.
University College Dublin1 Clipping u Clipping is the removal of all objects or part of objects in a modelled scene that are outside the real-world window.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Implementation I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Graphics Pipeline Clipping CMSC 435/634. Graphics Pipeline Object-order approach to rendering Sequence of operations – Vertex processing – Transforms.
2-Dimension Viewing and Clipping
CGMB 314 Intro to Computer Graphics Fill Area Primitives.
Windowing and clipping
CS 376 Introduction to Computer Graphics 02 / 12 / 2007 Instructor: Michael Eckmann.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 480/680 Computer Graphics Shading in OpenGL Dr. Frederick C Harris, Jr. Fall 2013.
Clipping CSCI 440 textbook section Starter Question How do we clip these lines? X=-5 Y=-5 Y=5 X=5 [0,0] [3,3] [7,-3] [0,-3] formula from wikipedia.
CSE Real Time Rendering Week 9. Post Geometry Shaders Courtesy: E. Angel and D. Shreiner – Interactive Computer Graphics 6E © Addison-Wesley 2012.
Windows, Viewports, and Clipping
Computer Graphics Filling. Filling Polygons So we can figure out how to draw lines and circles How do we go about drawing polygons? We use an incremental.
Computer Graphics Lecture 20 Fasih ur Rehman. Last Class Clipping – What is clipping – Why we do clipping – How clipping is done.
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
Clipping Primitives. Clipping line Clipping rectangle: – x min to x max – y min to y max A point (x,y) lies within a clip rectangle and thus displayed.
Graphics Graphics & Graphical Programming Lecture 23 - Viewing & Clipping.
Clipping. Before clipping… After clipping… Point Clipping Display P = (x, y) if xw min
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
1 U08181 Computer Graphics Clipping Transformations –Transformations and matrices –Homogeneous matrices –Transformations in SVG.
Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.
Computer Graphics Lecture 14 CLIPPING I Taqdees A. Siddiqi
Computer Graphic 2 D Viewing.
Computer Graphics Clipping.
Introduction to Computer Graphics with WebGL
Transformations contd.
CS 551 / 645: Introductory Computer Graphics
Computer Graphics Shading in OpenGL
Concepts, Algorithms for line clipping
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Concepts, algorithms for clipping
Implementation I Ed Angel
Graphics Pipeline Clipping
Computer Graphics : Viewing In 2D
CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Segment Clipping Simple algorithm. For each segment compute the intersection with the four sides of the rectangle, and then determine which sub-segment.
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Clipping Clipping Sutherland-Hodgman Clipping
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Clipping University of British Columbia CPSC 314 Computer Graphics
Implementation I Ed Angel Professor Emeritus of Computer Science
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Presentation transcript:

1 Computer Graphics Clipping Fall FCC 2006

Line Clipping What happens when one or both endpoints of a line segment are not inside the specified drawing area? Draw just the portions of a line (or object) that fall within a given region/window/screen (usually rectangular) Drawing Area

Line Clipping Strategies for clipping: a) Check (in inner loop) if each point is inside  Works, but slow b) Clip invalid coordinate(s) to boundary  Incorrect results c) Find intersection of line with boundary  Correct if (x >= xmin && x <= xmax && y >= ymin && y <= ymax) drawPoint(x,y,c); if (x < xmin) x = xmin; else if (x > xmax) x = xmax; if (y < ymin) y = ymin; else if (y > ymax) y = ymax; Input Output Clip x Clip y Clip line to intersection

Line Clipping: Possible Configurations 1.Both endpoints are inside the region (line AB)  No clipping necessary 2.One endpoint in, one out (line CD)  Clip at intersection point 3.Both endpoints outside the region: a. No intersection (lines EF, GH) b. Line intersects the region (line IJ) - Clip line at both intersection points A B C D F E I J G H

Line Clipping: Cohen-Sutherland Basic algorithm:  Accept (and draw) lines that have both endpoints inside the region F E Trivially reject A B Trivially accept H C D I J G Clip and retest  Clip the remaining lines at a region boundary and repeat steps 1 and 2 on the clipped line segments  Reject (and don’t draw) lines that have both endpoints less than x min or y min or greater than x max or y max

Cohen-Sutherland: Accept/Reject Tests Assign 4-bit code to each endpoint corresponding to its position relative to region:  Firstbit (1000) : if y > y max  Secondbit (0100) : if y < y min  Thirdbit (0010) : if x > x max  Fourthbit (0001) : if x < x min Test: if code 0 OR code 1 = 0000 accept (draw) else if code 0 AND code 1  0000 reject (don’t draw) else clip and retest

Cohen-Sutherland: Line Clipping Intersection algorithm: if code 0  0000 then code = code 0 else code = code 1 dx = x 1 – x 0 ; dy = y 1 – y 0 if code AND 1000 then begin // y max x = x 0 + dx * (y max – y 0 ) / dy; y = y max end else if code AND 0100 then begin // y min x = x 0 + dx * (y min – y 0 ) / dy; y = y min end else if code AND 0010 then begin // x max y = y 0 + dy * (x max – x 0 ) / dx; x = x max end else begin // x min y = y 0 + dy * (x min – x 0 ) / dx; x = x min end if code = code 0 thenbegin x 0 = x; y 0 = y; end elsebegin x 1 = x; y 1 = y; end (x 1, y 1 ) (x 0, y 0 ) y max y min dx dy (x, y) x min x max

Cohen-Sutherland: Line Clipping Example Intersection algorithm: if code 0  0000 then code = code 0 else code = code 1 dx = x 1 – x 0 ; dy = y 1 – y 0 if code AND 1000 then begin // y max x = x 0 + dx * (y max – y 0 ) / dy; y = y max end else if code AND 0100 then begin // y min x = x 0 + dx * (y min – y 0 ) / dy; y = y min end else if code AND 0010 then begin // x max y = y 0 + dy * (x max – x 0 ) / dx; x = x max end else begin // x min y = y 0 + dy * (x min – x 0 ) / dx; x = x min end if code = code 0 thenbegin x 0 = x; y 0 = y; end elsebegin x 1 = x; y 1 = y; end Codedxyxdy (x 1, y 1 ) (400, 300) Code (1010) (x 0, y 0 ) (150, 150) Code (0000) y max =200 y min =100 X min = 100x max = 300

Cohen-Sutherland: Line Clipping Example Intersection algorithm: if code 0  0000 then code = code 0 else code = code 1 dx = x 1 – x 0 ; dy = y 1 – y 0 if code AND 1000 then begin // y max x = x 0 + dx * (y max – y 0 ) / dy; y = y max end else if code AND 0100 then begin // y min x = x 0 + dx * (y min – y 0 ) / dy; y = y min end else if code AND 0010 then begin // x max y = y 0 + dy * (x max – x 0 ) / dx; x = x max end else begin // x min y = y 0 + dy * (x min – x 0 ) / dx; x = x min end if code = code 0 thenbegin x 0 = x; y 0 = y; end elsebegin x 1 = x; y 1 = y; end Codedxyxdy (x 1, y 1 ) (400, 300) Code (1010) (x 0, y 0 ) (150, 150) Code (0000) y max =200 y min =100 X min = 100x max = 300

Cohen-Sutherland: Line Clipping Example Intersection algorithm: if code 0  0000 then code = code 0 else code = code 1 dx = x 1 – x 0 ; dy = y 1 – y 0 if code AND 1000 then begin // y max x = x 0 + dx * (y max – y 0 ) / dy; y = y max end else if code AND 0100 then begin // y min x = x 0 + dx * (y min – y 0 ) / dy; y = y min end else if code AND 0010 then begin // x max y = y 0 + dy * (x max – x 0 ) / dx; x = x max end else begin // x min y = y 0 + dy * (x min – x 0 ) / dx; x = x min end if code = code 0 thenbegin x 0 = x; y 0 = y; end elsebegin x 1 = x; y 1 = y; end Code 1010 dxyxdy (x 1, y 1 ) (400, 300) Code (1010) (x 0, y 0 ) (150, 150) Code (0000) y max =200 y min =100 X min = 100x max = 300

Cohen-Sutherland: Line Clipping Example Intersection algorithm: if code 0  0000 then code = code 0 else code = code 1 dx = x 1 – x 0 ; dy = y 1 – y 0 if code AND 1000 then begin // y max x = x 0 + dx * (y max – y 0 ) / dy; y = y max end else if code AND 0100 then begin // y min x = x 0 + dx * (y min – y 0 ) / dy; y = y min end else if code AND 0010 then begin // x max y = y 0 + dy * (x max – x 0 ) / dx; x = x max end else begin // x min y = y 0 + dy * (x min – x 0 ) / dx; x = x min end if code = code 0 thenbegin x 0 = x; y 0 = y; end elsebegin x 1 = x; y 1 = y; end (x 1, y 1 ) (400, 300) Code (1010) (x 0, y 0 ) (150, 150) Code (0000) y max =200 y min =100 X min = 100x max = 300 Code 1010 dx 250 yxdy 150

Cohen-Sutherland: Line Clipping Example Intersection algorithm: if code 0  0000 then code = code 0 else code = code 1 dx = x 1 – x 0 ; dy = y 1 – y 0 if code AND 1000 then begin // y max x = x 0 + dx * (y max – y 0 ) / dy; y = y max end else if code AND 0100 then begin // y min x = x 0 + dx * (y min – y 0 ) / dy; y = y min end else if code AND 0010 then begin // x max y = y 0 + dy * (x max – x 0 ) / dx; x = x max end else begin // x min y = y 0 + dy * (x min – x 0 ) / dx; x = x min end if code = code 0 thenbegin x 0 = x; y 0 = y; end elsebegin x 1 = x; y 1 = y; end (x 1, y 1 ) (400, 300) Code (1010) (x 0, y 0 ) (150, 150) Code (0000) y max =200 y min =100 X min = 100x max = 300 Code 1010 dx 250 yxdy 150

Cohen-Sutherland: Line Clipping Example Intersection algorithm: if code 0  0000 then code = code 0 else code = code 1 dx = x 1 – x 0 ; dy = y 1 – y 0 if code AND 1000 then begin // y max x = x 0 + dx * (y max – y 0 ) / dy; y = y max end else if code AND 0100 then begin // y min x = x 0 + dx * (y min – y 0 ) / dy; y = y min end else if code AND 0010 then begin // x max y = y 0 + dy * (x max – x 0 ) / dx; x = x max end else begin // x min y = y 0 + dy * (x min – x 0 ) / dx; x = x min end if code = code 0 thenbegin x 0 = x; y 0 = y; end elsebegin x 1 = x; y 1 = y; end (x 1, y 1 ) (400, 300) Code (1010) (x 0, y 0 ) (150, 150) Code (0000) y max =200 y min =100 X min = 100x max = 300 Code 1010 dx 250 y 200 x 233 dy 150

Cohen-Sutherland: Line Clipping Example Intersection algorithm: if code 0  0000 then code = code 0 else code = code 1 dx = x 1 – x 0 ; dy = y 1 – y 0 if code AND 1000 then begin // y max x = x 0 + dx * (y max – y 0 ) / dy; y = y max end else if code AND 0100 then begin // y min x = x 0 + dx * (y min – y 0 ) / dy; y = y min end else if code AND 0010 then begin // x max y = y 0 + dy * (x max – x 0 ) / dx; x = x max end else begin // x min y = y 0 + dy * (x min – x 0 ) / dx; x = x min end if code = code 0 thenbegin x 0 = x; y 0 = y; end elsebegin x 1 = x; y 1 = y; end (x 1, y 1 ) (400, 300) Code (1010) (x 0, y 0 ) (150, 150) Code (0000) y max =200 y min =100 X min = 100x max = 300 Code 1010 dx 250 y 200 x 233 dy 150

Cohen-Sutherland: Line Clipping Example Intersection algorithm: if code 0  0000 then code = code 0 else code = code 1 dx = x 1 – x 0 ; dy = y 1 – y 0 if code AND 1000 then begin // y max x = x 0 + dx * (y max – y 0 ) / dy; y = y max end else if code AND 0100 then begin // y min x = x 0 + dx * (y min – y 0 ) / dy; y = y min end else if code AND 0010 then begin // x max y = y 0 + dy * (x max – x 0 ) / dx; x = x max end else begin // x min y = y 0 + dy * (x min – x 0 ) / dx; x = x min end if code = code 0 thenbegin x 0 = x; y 0 = y; end elsebegin x 1 = x; y 1 = y; end (x 1, y 1 ) (400, 300) Code (1010) (x 0, y 0 ) (150, 150) Code (0000) y max =200 y min =100 X min = 100x max = 300 Code 1010 dx 250 y 200 x 233 dy 150

Cohen-Sutherland: Line Clipping Summary 1.Choose an endpoint outside the clipping region 2.Using a consistent ordering (top to bottom, left to right) find a clipping border the line intersects 3.Discard the portion of the line from the endpoint to the intersection point 4.Set the new line to have as endpoints the new intersection point and the other original endpoint 5.You may need to run this several times on a single line (e.g., a line that crosses multiple clip boundaries)

Cohen-Sutherland Line Clip Examples A B E F G H C D I J A 0001 B 0100 OR 0101 AND 0000 subdivide C 0000 D 0010 OR 0010 AND 0000 subdivide E 0000 F 0000 OR 0000 AND 0000 accept G 0000 H 1010 OR 1010 AND 0000 subdivide I 0110 J 0010 OR 0110 AND 0010 reject

Cohen-Sutherland Line Clip Examples A B G H C D A 0001 A’ 0001 remove A’ G’ C’ A’ 0001 B 0100 OR 0101 AND 0000 subdivide C 0000 C’ 0000 OR 0000 AND 0000 accept C’ 0000 D 1010 remove G 0000 G’ 0000 OR 0000 AND 0000 accept G’ 0000 H 1010 remove

Cohen-Sutherland Line Clip Examples B’ B A’ 0001 B’ 0100 remove A’ B’ 0100 B 0100 OR 0100 AND 0100 reject

Polygon Clipping What about polygons? For concave polygons, the intersection with the clipping region may be complex

Polygon Clipping: Algorithm Clip polygon to y min and y max :  Create empty output vertex list (list out = empty)  Process input list (list in = (v 0, v 1, …, v n ) where v 0 = v n ) in order  For each input vertex (v i where 0  i  n–1) : - If v i is inside region  Add v i to end of list out - If the line between v i and v i+1 intersects specified boundaries  Add intersection point(s) to end of list out Repeat: clipping to x min and x max Post-process:  Find “degenerate” sections where both sides of polygon has collapsed to region boundary  Remove those sections  Create new polygon

Polygon Clipping: Example Clip first to y min and y max y min y max v0v0 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 v7v7 v8v8 v9v9 Input vertex list: (v 0, v 1, v 2, v 3, v 4, v 5, v 6, v 7, v 8, v 9 ) vertex: v 0 inside region: no add p 0 to output list Output vertex list: p0p0 line intersect boundary: yes (p0)(p0)

Polygon Clipping: Example Clip first to y min and y max y min y max v0v0 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 v7v7 v8v8 v9v9 Input vertex list: (v 0, v 1, v 2, v 3, v 4, v 5, v 6, v 7, v 8, v 9 ) vertex: v 1 inside region: yes add v 1 to output list Output vertex list: p0p0 line intersect boundary: no (p 0, v 1 )

Polygon Clipping: Example Clip first to y min and y max y min y max v0v0 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 v7v7 v8v8 v9v9 Input vertex list: (v 0, v 1, v 2, v 3, v 4, v 5, v 6, v 7, v 8, v 9 ) vertex: v 2 inside region: yes add v 2, p 1 to output list Output vertex list: p0p0 (p 0, v 1, v 2, p 1 ) line intersect boundary: yes p1p1

Polygon Clipping: Example Clip first to y min and y max y min y max v0v0 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 v7v7 v8v8 v9v9 Input vertex list: (v 0, v 1, v 2, v 3, v 4, v 5, v 6, v 7, v 8, v 9 ) vertex: v 3 inside region: no Output vertex list: p0p0 (p 0, v 1, v 2, p 1 ) line intersect boundary: no p1p1

Polygon Clipping: Example Clip first to y min and y max y min y max v0v0 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 v7v7 v8v8 v9v9 Input vertex list: (v 0, v 1, v 2, v 3, v 4, v 5, v 6, v 7, v 8, v 9 ) vertex: v 4 inside region: no add p 2 to output list Output vertex list: p0p0 (p 0, v 1, v 2, p 1, p 2 ) p1p1 line intersect boundary: yes p2p2

Polygon Clipping: Example Clip first to y min and y max y min y max v0v0 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 v7v7 v8v8 v9v9 Input vertex list: (v 0, v 1, v 2, v 3, v 4, v 5, v 6, v 7, v 8, v 9 ) vertex: v 5 inside region: yes add v 5, p 3 to output list Output vertex list: p0p0 (p 0, v 1, v 2, p 1, p 2, v 5, p 3 ) p1p1 p2p2 line intersect boundary: yes p3p3

Polygon Clipping: Example Clip first to y min and y max y min y max v0v0 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 v7v7 v8v8 v9v9 Input vertex list: (v 0, v 1, v 2, v 3, v 4, v 5, v 6, v 7, v 8, v 9 ) vertex: v 6 inside region: no Output vertex list: p0p0 (p 0, v 1, v 2, p 1, p 2, v 5, p 3 ) p1p1 p2p2 line intersect boundary: no p3p3

Polygon Clipping: Example Clip first to y min and y max y min y max v0v0 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 v7v7 v8v8 v9v9 Input vertex list: (v 0, v 1, v 2, v 3, v 4, v 5, v 6, v 7, v 8, v 9 ) vertex: v 7 inside region: no Output vertex list: p0p0 (p 0, v 1, v 2, p 1, p 2, v 5, p 3 ) p1p1 p2p2 line intersect boundary: no p3p3

Polygon Clipping: Example Clip first to y min and y max y min y max v0v0 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 v7v7 v8v8 v9v9 Input vertex list: (v 0, v 1, v 2, v 3, v 4, v 5, v 6, v 7, v 8, v 9 ) vertex: v 8 inside region: no add p 4 to output list Output vertex list: p0p0 (p 0, v 1, v 2, p 1, p 2, v 5, p 3, p 4 ) p1p1 p2p2 p3p3 line intersect boundary: yes p4p4

Polygon Clipping: Example Clip first to y min and y max y min y max v0v0 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 v7v7 v8v8 v9v9 Input vertex list: (v 0, v 1, v 2, v 3, v 4, v 5, v 6, v 7, v 8, v 9 ) vertex: v 9 inside region: yes add v 9, p 5 to output list Output vertex list: p0p0 (p 0, v 1, v 2, p 1, p 2, v 5, p 3, p 4, v 9, p 5 ) p1p1 p2p2 p3p3 p4p4 line intersect boundary: yes p5p5

Polygon Clipping: Example This gives us a new polygon y min y max v1v1 v2v2 v5v5 v9v9 with vertices: p0p0 (p 0, v 1, v 2, p 1, p 2, v 5, p 3, p 4, v 9, p 5 ) p1p1 p2p2 p3p3 p4p4 p5p5

Polygon Clipping: Example (cont.) Now clip to x min and x max x min x max Input vertex list: = (p 0, v 1, v 2, p 1, p 2, v 5, p 3, p 4, v 9, p 5 ) Output vertex list: (p 0, p 6, p 7, v 2, p 1, p 8, p 9, p 3, p 4, v 9, p 5 ) v1v1 v2v2 v5v5 v9v9 p0p0 p1p1 p2p2 p3p3 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9

Polygon Clipping: Example (cont.) Now post-process x min x max v9v9 v3v3 Output vertex list: (p 0, p 6, p 7, v 2, p 1, p 8, p 9, p 3, p 4, v 9, p 5 ) Post-process: (p 0, p 6, p 9, p 3,) and (p 7, v 2, p 1, p 8 ) and (v 4, v 9, p 5 ) p8p8 p6p6 v2v2 p7p7 p0p0 p5p5 p3p3 p4p4 p9p9 p1p1

Polygon Orientation positive Negative A B C D E L R A E D C B L R

Left o Right Let A(x1,y1) and B(x2,y2) end points of a line. A point P(x,y) will be to the left of the line segment if the expresion C= (x2-x1)*(y-y1)-(y2-y1)*(x-x1) is positive. We say the point is to the right if C is negative. If P is to the right, it is outside the Polygon If P is to the left, it is inside the Polygon