How to use the d3-polygon.polygonContains function in d3-polygon

To help you get started, we’ve selected a few d3-polygon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / d3-polygon / d3-polygon-tests.ts View on Github external
let point: [number, number] = [15, 15];
let polygon: Array<[number, number]> = [[10, 10], [20, 20], [10, 30]];
let pointArray: Array<[number, number]> = [[10, 10], [20, 20], [10, 30], [15, 15]];
let hull: Array<[number, number]>;

// -----------------------------------------------------------------------------
// Tests
// -----------------------------------------------------------------------------

num = d3Polygon.polygonArea(polygon);

point = d3Polygon.polygonCentroid(polygon);

hull = d3Polygon.polygonHull(pointArray);

containsFlag = d3Polygon.polygonContains(polygon, point);

num = d3Polygon.polygonLength(polygon);
github DefinitelyTyped / DefinitelyTyped / types / d3-polygon / d3-polygon-tests.ts View on Github external
let point: [number, number] = [15, 15];
let polygon: Array<[number, number]> = [[10, 10], [20, 20], [10, 30]];
let pointArray: Array<[number, number]> = [[10, 10], [20, 20], [10, 30], [15, 15]];
let hull: Array<[number, number]>;

// -----------------------------------------------------------------------------
// Tests
// -----------------------------------------------------------------------------

num = d3Polygon.polygonArea(polygon);

point = d3Polygon.polygonCentroid(polygon);

hull = d3Polygon.polygonHull(pointArray);

containsFlag = d3Polygon.polygonContains(polygon, point);

num = d3Polygon.polygonLength(polygon);
github bmershon / scissors / src / equidecompose / rectangle2Rectangle.js View on Github external
halved.forEach(function(d, j) {
      centroid = polygonCentroid(d);

      // update exact references to vertices used in exact intersections
      d.forEach(function(V, k) { // scan vertices
        if (Object.is(E, V)) {
          E_Polygon.push(j);
          E_Vertex.push(k);
        } else if (Object.is(F, V)) {
          F_Polygon.push(j);
          F_Vertex.push(k);
        }
      });

      if (polygonContains(left, centroid)) { // slide "up"
        d.translate(slideUp).transforms.push({translate: scale(-1, slideUp)}); // undo translate
      } else { // slide "left"
        d.translate(slideLeft).transforms.push({translate: scale(-1, slideLeft)}); // undo translate
      }
    });
github Kcnarf / d3-voronoi-map / src / d3-voronoi-map.js View on Github external
return basePoints.map(function(bp, i, bps) {
      initialPosition = bp.initialPosition;

      if (!d3PolygonContains(weightedVoronoi.clip(), initialPosition)) {
        initialPosition = DEFAULT_INITIAL_POSITION(bp, i, bps, simulation);
      }

      return {
        index: bp.index,
        targetedArea: (totalArea * bp.weight) / totalWeight,
        data: bp,
        x: initialPosition[0],
        y: initialPosition[1],
        weight: bp.initialWeight // ArlindNocaj/Voronoi-Treemap-Library uses an epsilonesque initial weight; using heavier initial weights allows faster weight adjustements, hence faster stabilization
      };
    });
  }
github bmershon / scissors / src / equidecompose / rectangle2Rectangle.js View on Github external
polygons.forEach(function(d) {
    var centroid, T;

    centroid = polygonCentroid(d);

    if (polygonContains(KCF, centroid)) {
      T = sub(A, K);
      d.translate(T).transforms.push({translate: scale(-1, T)});
    } else if (polygonContains(AFGD, centroid)) {
      T = sub(A, J);
      d.translate(T).transforms.push({translate: scale(-1, T)});
    }
  });
github bmershon / scissors / src / polygon / polygon.js View on Github external
function containsPoint(point){
  return polygonContains(this, point);
}
github bmershon / scissors / src / geom / triangulate.js View on Github external
triangles = layout.triangles(vertices).filter(function(d) {
    return polygonContains(vertices, polygonCentroid(d));
  });
github bmershon / scissors / src / equidecompose / rectangle2Rectangle.js View on Github external
polygons.forEach(function(d) {
    var centroid, T;

    centroid = polygonCentroid(d);

    if (polygonContains(KCF, centroid)) {
      T = sub(A, K);
      d.translate(T).transforms.push({translate: scale(-1, T)});
    } else if (polygonContains(AFGD, centroid)) {
      T = sub(A, J);
      d.translate(T).transforms.push({translate: scale(-1, T)});
    }
  });
github bmershon / scissors / src / rectangle2Square.js View on Github external
polygons.forEach(function(d) {
    var centroid, T;

    centroid = polygonCentroid(d);

    if (polygonContains(KCF, centroid)) {
      T = sub(A, K);
      d.translate(T).transforms.push({translate: scale(-1, T)});
    } else if (polygonContains(AFGD, centroid)) {
      T = sub(A, J);
      d.translate(T).transforms.push({translate: scale(-1, T)});
    }
  });
github larsvers / d3-hexgrid / src / getPolygonPoints.js View on Github external
const areaPoints = gridPoints.filter(point =>
        polygonContains(boundary, [point.x, point.y])
      );

d3-polygon

Operations for two-dimensional polygons.

ISC
Latest version published 3 years ago

Package Health Score

71 / 100
Full package analysis