0
28kviews
what is the purpose of Inside - outside Tests?Explain with an example.

Mumbai University > Computer Engineering > Sem 4 > Computer Graphics

Marks: 5 Marks

Year: Dec 2016

1 Answer
4
1.2kviews

Inside-outside Test:

This method is also known as counting number method. While filling an object, we often need to identify whether particular point is inside the object or outside it. There are two methods by which we can identify whether particular point is inside an object or outside.

  1. Odd-Even Rule

  2. Nonzero winding number rule

Odd-Even Rule:

In this technique, we will count the edge crossing along the line from any point (x,y) to infinity. If the number of interactions is odd, then the point (x,y) is an interior point; and if the number of interactions is even, then the point (x,y) is an exterior point. The following example depicts this concept.

enter image description here

From the above figure, we can see that from the point (x,y), the number of interactions point on the left side is 5 and on the right side is 3. From both ends, the number of interaction points is odd, so the point is considered within the object.

Nonzero Winding Number Rule:

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.

enter image description here

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.
Please log in to add an answer.