06-PolyRast

06-PolyRast - Rasterizing Polygons Given a set of vertices...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Rasterizing Polygons Given a set of vertices and edges, find the pixels that fill the polygon.
Background image of page 2
Rasterizing Polygons fillPoly(vertex vList[ ]) boundingBox b = getBounds(vList); int xmin = b.minX; int xmax = b.maxX; int ymin = b.minY; int ymax = b.maxY; for(int y = ymin; y <= ymax; y++) for(int x = xmin; x <= xmax; x++) if(insidePoly(x,y,vList)) setPixel(x,y); vList is an ordered list of the polygon’s vertices
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
What does 'inside' mean? How to test if a point is inside a polygon ! Half-space tests ! Jordan Curve Theorem (even/odd or +1/-1) ! 'winding number' tests
Background image of page 4
Half Space Tests Given the edges of a triangle, the inside is the intersection of half-spaces defined by the edges Find in-plane normal to each edge, dot it with (pt,vertex) rays. ALL such dot products will be of same sign for points inside (or outside).
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Half Space Tests Easily computable: Doesn’t work on concave objects!! (triangulate) IN OUT OUT 0 ) , ( < + + = c by ax y x l Iff (x,y) is inside
Background image of page 6
Half Space Tests fillTriangle(vertex vList[3]) //-- get the bounding box as before --// float e1 = lineEq(vList[0],vList[1],xmin,ymin); float e2 = lineEq(vList[1],vList[2],xmin,ymin); float e3 = lineEq(vList[2],vList[0],xmin,ymin); int xDim = xMax - xMin; for(int y = ymin; y <= ymax; y++) for(int x = xmin; x <= xmax; x++) if(e1<0 && e2<0 && e3<0) setPixel(x,y); e1 += a1; e2 += a2; e3+= a3; e1 += -xDim*a1+b1; e2 = -xDim*a2+b2; e3 = -xDim*a3+b3 lineEq computes the implicit line value for 2 vertices & a point
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/27/2010 for the course CSCI 480 taught by Professor Sathyanaraya during the Spring '08 term at USC.

Page1 / 32

06-PolyRast - Rasterizing Polygons Given a set of vertices...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online