Computer Science Related Others Courses AvailableThe Best Codder.blogspot.com

Inside-outside Test

 

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.

  • Odd-Even Rule
  • Nonzero winding number rule

Odd-Even Rule

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

Odd-Even Rule

From the above figure, we can see that from the point ,, 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.

Nonzero Winding

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.

Post a Comment

© Computer Graphics. The Best Codder All rights reserved. Distributed by