isInPolygon(polygon) {
    let inside = false; // Its not always a given, that the polygon is convex (-> sugars)

    for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
      if (polygon[i].y > this.y != polygon[j].y > this.y && this.x < (polygon[j].x - polygon[i].x) * (this.y - polygon[i].y) / (polygon[j].y - polygon[i].y) + polygon[i].x) {
        inside = !inside;
      }
    }

    return inside;
  }
Checks whether a vector lies within a polygon spanned by a set of vectors.

@param {Vector2[]} polygon An array of vectors spanning the polygon.
@returns {Boolean} A boolean indicating whether or not this vector is within a polygon.