/**
 * Copyright (c) 2014 by Wen Yu.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Any modifications to this file must keep this entire header intact.
 */

package cafe.graphics.util;

/** 
 * This utility class contains static methods 
 * to work with geometry. 
 * 
 * @author Wen Yu, yuwen_66@yahoo.com
 * @version 1.0 04/15/2013
 */
public class GeoUtils {

	private GeoUtils() {} // Prevents instantiation
	
	public static boolean isInsidePoly(int npol, int[] xp, int[] yp, int x, int y)
	{		
	     int i, j;
	     boolean c = false;
	     
	     for (i = 0, j = npol-1; i < npol; j = i++) {
	           if ((((yp[i]<=y) && (y<yp[j])) ||((yp[j]<=y) && (y<yp[i]))) &&
	                (x < (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i]))
	              c = !c;
	     }
	     
	     return c;
	}   

	public static boolean isInsidePoly(int npol, double[] xp, double[] yp, double x, double y)
	{
		int i, j;
		boolean c = false;
     
		for (i = 0, j = npol-1; i < npol; j = i++) {
			if ((((yp[i]<=y) && (y<yp[j])) ||((yp[j]<=y) && (y<yp[i]))) &&
					(x < (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i]))
				c = !c;
		}
     
		return c;
	}   
}
@@ -653,20 +653,24 @@
 oly(int 
-npol
+x, int y
 , int%5B%5D 
@@ -685,22 +685,8 @@
 %5D yp
-, int x, int y
 )%0A%09%7B
@@ -729,16 +729,44 @@
  false;%0A
+%09     int npol = xp.length;%0A
 %09     %0A%09
@@ -1026,20 +1026,18 @@
 rn c;%0A%09%7D
-   
 %0A
+%09
 %0A%09public
@@ -1069,37 +1069,384 @@
 oly(
-int npol, 
+float x, float y, float%5B%5D xp, float%5B%5D yp)%0A%09%7B%0A%09%09int i, j;%0A%09%09boolean c = false;%0A%09%09int npol = xp.length;%0A%09%09%0A%09%09for (i = 0, j = npol-1; i %3C npol; j = i++) %7B%0A%09%09%09if ((((yp%5Bi%5D%3C=y) && (y%3Cyp%5Bj%5D)) %7C%7C((yp%5Bj%5D%3C=y) && (y%3Cyp%5Bi%5D))) &&%0A%09%09%09%09%09(x %3C (xp%5Bj%5D - xp%5Bi%5D) * (y - yp%5Bi%5D) / (yp%5Bj%5D - yp%5Bi%5D) + xp%5Bi%5D))%0A%09%09%09%09c = !c;%0A%09%09%7D%0A     %0A%09%09return c;%0A%09%7D%0A%0A%09public static boolean isInsidePoly(
 double
-%5B%5D
  x
-p
 , double
 %5B%5D y
@@ -1445,21 +1445,18 @@
 uble
-%5B%5D
  y
-p
 , double
  x, 
@@ -1451,26 +1451,29 @@
 , double
+%5B%5D
  x
+p
 , double
  y)%0A%09%7B%0A%09
@@ -1464,18 +1464,21 @@
 , double
+%5B%5D
  y
+p
 )%0A%09%7B%0A%09%09i
@@ -1507,21 +1507,42 @@
  false;%0A
-     
+%09%09int npol = xp.length;%0A%09%09
 %0A%09%09for (

remove unnecessary parameters