function testGeoPolygonRect(geopolygon, rect) {
  const [p1, p2, p3, p4] = rectToPoints(rect);
  if (
    testGeoPolygonPoint(geopolygon, p1) ||
    testGeoPolygonPoint(geopolygon, p2) ||
    testGeoPolygonPoint(geopolygon, p3) ||
    testGeoPolygonPoint(geopolygon, p4)
  ) {
    return true;
  }
  const { numPolygons, polygons } = geopolygon;
  for (let n = 0; n < numPolygons; n++) {
    const polygon = polygons[n];
    for (let i = 0, num = polygon.edges.length; i < num; i++) {
      const edge = pointsToLine(polygon.edges[i]);
      if (testRectLine(rect, edge)) {
        return true;
      }
    }
  }
  return false;
}
/**
 * Test if a GeoPolygon collider with a rectangle. If so, returns true and false otherwise.
 * Rectangle must have width and height greater than 0.
 * @private
 * @param {object} geopolygon
 * @param {Array} geopolygon.polygons - Array of polygons
 * @param {object} rect
 * @param {number} rect.x - x-coordinate
 * @param {number} rect.y - y-coordinate
 * @param {number} rect.width - width
 * @param {number} rect.height - height
 * @return {boolean} true if polygon collider with rect
 */
Test if a GeoPolygon collider with a rectangle. If so, returns true and false otherwise.
Rectangle must have width and height greater than 0.
Test if a GeoPolygon collider with a rectangle . If so returns true and false otherwise . Rectangle must have width and height greater than 0 .
function testGeoPolygonRect(geopolygon, rect) {
  const [p1, p2, p3, p4] = rectToPoints(rect);
  if (
    testGeoPolygonPoint(geopolygon, p1) ||
    testGeoPolygonPoint(geopolygon, p2) ||
    testGeoPolygonPoint(geopolygon, p3) ||
    testGeoPolygonPoint(geopolygon, p4)
  ) {
    return true;
  }
  const { numPolygons, polygons } = geopolygon;
  for (let n = 0; n < numPolygons; n++) {
    const polygon = polygons[n];
    for (let i = 0, num = polygon.edges.length; i < num; i++) {
      const edge = pointsToLine(polygon.edges[i]);
      if (testRectLine(rect, edge)) {
        return true;
      }
    }
  }
  return false;
}
function testGeoPolygonRect ( geopolygon , rect ) { const [ p1 , p2 , p3 , p4 ] = rectToPoints ( rect ) ; if ( testGeoPolygonPoint ( geopolygon , p1 ) || testGeoPolygonPoint ( geopolygon , p2 ) || testGeoPolygonPoint ( geopolygon , p3 ) || testGeoPolygonPoint ( geopolygon , p4 ) ) { return true ; } const { numPolygons , polygons } = geopolygon ; for ( let n = 0 ; n < numPolygons ; n ++ ) { const polygon = polygons [ n ] ; for ( let i = 0 , num = polygon . edges . length ; i < num ; i ++ ) { const edge = pointsToLine ( polygon . edges [ i ] ) ; if ( testRectLine ( rect , edge ) ) { return true ; } } } return false ; }
Test if a GeoPolygon collider with a rectangle.
Test if a GeoPolygon collider with a rectangle .