Presentation is loading. Please wait.

Presentation is loading. Please wait.

Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.

Similar presentations


Presentation on theme: "Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a."— Presentation transcript:

1 Part 6: Graphics Output Primitives (4) 1

2  Another useful construct,besides points, straight line segments, and curves for describing components of a picture is an area that is filled with some solid color or pattern. A picture component of this type is typically referred to as a fill area or filled area.  Although any filled shape is possible, graphics libraries generally do not support specifications for arbitrary fill shapes.  Most library routines require that a fill area be specified as a polygon. 2

3  Graphics routines can more efficiently process polygons than other kinds of fill shapes because polygon boundaries are described with linear equations.  Approximating a curved surface with polygon facets is sometimes referred to as surface tessellation. 3

4  Mathematically defined, a polygon is a plane figure specified by a set of three or more coordinate positions called vertices that are connected in sequence by straight line segments called the edges.  Further in basic geometry it is required that the polygon edges have no common point other than their end points.  Thus, by definition a polygon must have all its vertices on the same plane. And there can be no edges crossings. 4

5  An interior angle of a polygon is an angle inside the polygon boundary that is formed by two adjacent edges.  If all interior angles of a polygon are less or equal 180 degrees, the polygon is a convex polygon.  Otherwise if the polygon has an angle with greater than 180 degrees it is called a concave polygon.  Concave polygons also present problems. Implementations of fill algorithms and other graphics routines are more complicated for concave polygons, so it is generally more efficient to split a concave into a set of convex polygons before processing. 5

6 convex polygon (a) concave polygon (b) 6

7  If we set up a vector for each polygon edge, then we can use the cross produce of adjacent edges to test for concavity.  All such vector products will be of the same sign( positive or negative) for a convex polygon.  Therefore, if some cross products yield a positive value and some a negative value we have a concave polygon. 7

8 x y V6 E1 E3 E2 V1 E4 E6 E5 V4 V3 V2 V5 (E1 X E2) >0 (E2 X E3) >0 (E3 X E4) <0 (E4 X E5) >0 (E5 X E6) >0 (E6 X E1) >0 8

9  Once we have identified that we have a concave polygon we must split it into a set of convex polygons, we have two methods for splitting the concave : 1- The vector method. 2- The rotational method. 9

10  With this method we first need to form the edge vectors, consider consecutive edge vectors V k, and V k+1, we define the edge vector between them as : Ek=V k+1 – V k  Now we calculate the edge vectors cross product and define where is the vertex that caused the concave to appear. 10

11  If the value of some cross product is positive while the others are negative the polygon is concave,else, it is a convex.  To illustrate the vertex method we do the following example : 11

12  Given a concave polygon with six edges, for this shape the edges are expressed as: E1 =(1,0,0) E2=(1,1,0) E3=(1,-1,0) E4=(0,3,0) E5=(-3,0,0) E6=(0,-3,0) where the z component is 0, since all edges are in the xy plane. V1 =(0,0,0) V2=(1,0,0) V3=(2,1,0) V4=(3,0,0) V5=(3,3,0) V6=(0,3,0) 12

13 So the vectors cross products are: E1 X E2 =(0,0,1) E2 X E3 =(0,0,-2) E3 X E4 =(0,0,2) E4 X E5 =(0,0,9) E5 X E6 =(0,0,9) E6 X E1=(0,0,2) Where V1 X V2= (V 1y V 2z -V 1z V 2y, V 1z V 2x -V 1x V 2z, V 1x V 2y -V 1y V 2x ). As shown at E2 the value is negative, so we split the polygon at E2. 13

14 Another methods to split the polygon is to use the rotational method. We shift the position of the polygon so that each vertex V k in turn is at the coordinate origin. Then, we rotate the polygon in clockwise direction so the next point V k+1 is on the x axis. If the next vertex V k+2 is below the x axis, the polygon is a concave. we then split the polygon along the x axis to form two new polygons. 14

15 15

16 16

17 17


Download ppt "Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a."

Similar presentations


Ads by Google