CG Ia 2
CG Ia 2
Decision parameter:
Initially, we have two decision parameters p1 0 in region 1 and
p20 in region 2.
These parameters are defined as : p1 0 in region 1 is given as :
p10=ry2+1/4rx2-rx2ry
Q5,6,7) ans:
Odd-Even :
In this technique, we will count the edge crossing along the line from any
point x,yx,y to infinity. If the number of interactions is odd, then the point
x,yx,y is an interior point; and if the number of interactions is even, then
the point x,yx,y is an exterior point. The following example depicts this
concept
Now we need to count the number of intersection of that line with
the line segments of the polygon. “If the number of intersection
is odd then we say the point is inside the polygon and if
number of intersection is even then we say the point is
outside the polygon”. In our example we can see the number of
intersection is 3 which is odd that means the point is inside the
polygon.
Now consider the second point and repeat the same procedure as
we did for the first one, we got 2 intersections which means the
point is outside the polygon.
This method is also used with the simple polygons to test the given
point is interior or not. It can be simply understood with the help of a
pin and a rubber band. Fix up the pin on one of the edge of the polygon
and tie-up the rubber band in it and then stretch the rubber band along
the edges of the polygon. When all the edges of the polygon are
covered by the rubber band, check out the pin which has been fixed up
at the point to be test. If we find at least one wind at the point consider
it within the polygon, else we can say that the point is not inside the
polygon
In another alternative method, give directions to all the edges of the
polygon. Draw a scan line from the point to be test towards the left
most of X direction.
• Give the value 1 to all the edges which are going to upward direction
and all other -1 as direction values.
• Check the edge direction values from which the scan line is passing
and sum up them.
• If the total sum of this direction value is non-zero, then this point to
be tested is an interior point, otherwise it is an exterior point.
• In the above figure, we sum up the direction values from which the
scan line is passing then the total is 1 – 1 + 1 = 1; which is non-zero. So
the point is said to be an interior point
Q8)
Q8)
Boundary fill:
Boundary fill is the algorithm used frequently in computer graphics to
fill a desired color inside a closed polygon having the same boundary
color for all of its sides. Algorithm:
1. Take the position of the starting point and the boundary color
2. Decide wether you want to go in 4 directions (N, S, W, E) or 8
directions (N, S, W, E, NW, NE, SW, SE). 3. Choose a fill color.
4. Travel in those directions.
5. If the pixel you land on is not the fill color or the boundary color ,
replace it with the fill color.
6. Repeat 4 and 5 until you’ve been everywhere within the boundaries.
Flood Fill
Q12)
Q9)(4 connected polygon)
Step 6 – Exit