Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
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);
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
}
});
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
};
});
}
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)});
}
});
function containsPoint(point){
return polygonContains(this, point);
}
triangles = layout.triangles(vertices).filter(function(d) {
return polygonContains(vertices, polygonCentroid(d));
});
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)});
}
});
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)});
}
});
const areaPoints = gridPoints.filter(point =>
polygonContains(boundary, [point.x, point.y])
);