title: Calculate if an object is inside a set of coordinates?
body: <p>I have a set of X and Y points that builds a shape and I need to know if an object is inside it or not what is the calculation to it ?</p>
  
  <p>X and Y coords example:</p>
  
  <pre><code>522.56055 2389.885
  544.96 2386.3406
  554.18616 2369.2385
  535.21814 2351.396
  497.5552 2355.8396
  </code></pre>
  
  <p>I am not really good with math :( so i would appreciate some support to understand how it is done.</p>
  
  <p>Example of what I have so far but doesnt seem very reliable:</p>
  
  <pre><code>private boolean isInsideShape(Zone verifyZone, Position object)
  {
      int corners = verifyZone.getCorners();
      float[] xCoords = verifyZone.getxCoordinates();
      float[] yCoords = verifyZone.getyCoordinates();
  
      float x = object.getX();
      float y = object.getY();
      float z = object.getZ();
  
      int i, j = corners - 1;
      boolean inside = false;
  
      for(i = 0; i &lt; corners; i++)
      {
          if(yCoords[i] &lt; y &amp;&amp; yCoords[j] &gt;= y || yCoords[j] &lt; y &amp;&amp; yCoords[i] &gt;= y)
              if(xCoords[i] + (y - yCoords[i]) / (yCoords[j] - yCoords[i]) * (xCoords[j] - xCoords[i]) &lt; x)
                  inside = !inside;
          j = i;
      }
  
      return inside;
  }
  </code></pre>