- 64 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about ' Processing Polygons' - annice

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

A polygon is a many-sided planar figure composed of vertices and edges.

Vertices are represented by points (x,y).

Edges are represented as line segments which connect two points, (x1,y1) and (x2,y2).

P = { (xi , yi ) } i=1,n

E1

(x1,y1)

(x2,y2)

E2

E3

(x3,y3)

PolygonsConvex Polygon - For any two point s P1, P2 inside the polygon, all points on the line segment which connects P1 and P2 are inside the polygon.

All points P = uP1 + (1-u)P2, u in [0,1] are inside the polygon provided that P1 and P2 are inside the polygon.

Concave Polygon - A polygon which is not convex.

Convex and Concave PolygonsHow do we know a point is "inside" a polygon?

Inside test: A point P is inside a polygon if and only if a scanline intersects the polygon edges an odd number of times moving from P in either direction.

1

3

2

1

Inside Polygon TestProblem when scan line crosses a vertex:

Does the vertex count as two points?

Or should it count as one point?

When crossing a vertex, if the vertex is a local maximum or minimum (in y) then count it twice, else count it once.

or

or

Count twice

Count once

Max-Min TestFill the polygon 1 scanline at a time

Determine which pixels on each scanline are inside the polygon and set those pixels to the appropriate value.

Look only for those pixels at which changes occur.

Filling PolygonsFor each scan-line:

1. Find the intersections of the scan line with all edges of the polygon.

2. Sort the intersections by increasing x-coordinate.

3. Fill in all pixels between pairs of intersections.

Possible Problems

1. Horizontal edges ==> Ignore

2. Vertices ==> If local max or min, then count twice, else count once. (This is implemented by shortening an edge by one pixel.)

3. Calculating intersections is slow.

8

6

4

2

Scan-Line AlgorithmFor scan-line number 7 the sorted list of x-coordinates is (1,3,7,9)

Therefore fill pixels with x-coordinates 1-3 and 7-9.

Not all edges intersect each scan line.

Many edges intersected by scan line i will also be intersected by scan line i+l

Formula for scan line s is y = s,

for an edge is y = mx + b

Their intersection of a scan line and an edge is

s = mxs + b therefore xs = (s-b)/m

For scan line s + 1,

xs+1 = (s+1 - b)/m

= xs + 1/m

Edge Coherence
Download Presentation

Connecting to Server..