From 68cd2f345a7d74c86fc9719106d2f4d78bf73384 Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Sat, 28 Sep 2013 20:45:01 +0200 Subject: [PATCH] GeometryUtils: add docs --- vtm/src/org/oscim/utils/GeometryUtils.java | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/vtm/src/org/oscim/utils/GeometryUtils.java b/vtm/src/org/oscim/utils/GeometryUtils.java index 92a57084..222cc3ce 100644 --- a/vtm/src/org/oscim/utils/GeometryUtils.java +++ b/vtm/src/org/oscim/utils/GeometryUtils.java @@ -19,10 +19,30 @@ public final class GeometryUtils { private GeometryUtils() { } - // from www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html /** - * test if point x/y is in polygon defined by vertices[offset ... + * Test if point x/y is in polygon defined by vertices[offset ... * offset+length] + *

+ * -- from www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html + *

+ * If there is only one connected component, then it is optional to repeat + * the first vertex at the end. It's also optional to surround the component + * with zero vertices. + *

+ * The polygon may contain multiple separate components, and/or holes, + * provided that you separate the components and holes with a (0,0) vertex, + * as follows. + *

  • First, include a (0,0) vertex. + *
  • Then include the first component' vertices, repeating its first + * vertex after the last vertex. + *
  • Include another (0,0) vertex. + *
  • Include another component or hole, repeating its first vertex after + * the last vertex. + *
  • Repeat the above two steps for each component and hole. + *
  • Include a final (0,0) vertex. + *

    + * Each component or hole's vertices may be listed either clockwise or + * counter-clockwise. */ public static boolean pointInPoly(float x, float y, float[] vertices, int length, int offset) {