Initial commit
This commit is contained in:
27
node_modules/d3-polygon/LICENSE
generated
vendored
Normal file
27
node_modules/d3-polygon/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
Copyright 2010-2016 Mike Bostock
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the author nor the names of contributors may be used to
|
||||
endorse or promote products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
150
node_modules/d3-polygon/build/d3-polygon.js
generated
vendored
Normal file
150
node_modules/d3-polygon/build/d3-polygon.js
generated
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
// https://d3js.org/d3-polygon/ Version 1.0.3. Copyright 2017 Mike Bostock.
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(factory((global.d3 = global.d3 || {})));
|
||||
}(this, (function (exports) { 'use strict';
|
||||
|
||||
var area = function(polygon) {
|
||||
var i = -1,
|
||||
n = polygon.length,
|
||||
a,
|
||||
b = polygon[n - 1],
|
||||
area = 0;
|
||||
|
||||
while (++i < n) {
|
||||
a = b;
|
||||
b = polygon[i];
|
||||
area += a[1] * b[0] - a[0] * b[1];
|
||||
}
|
||||
|
||||
return area / 2;
|
||||
};
|
||||
|
||||
var centroid = function(polygon) {
|
||||
var i = -1,
|
||||
n = polygon.length,
|
||||
x = 0,
|
||||
y = 0,
|
||||
a,
|
||||
b = polygon[n - 1],
|
||||
c,
|
||||
k = 0;
|
||||
|
||||
while (++i < n) {
|
||||
a = b;
|
||||
b = polygon[i];
|
||||
k += c = a[0] * b[1] - b[0] * a[1];
|
||||
x += (a[0] + b[0]) * c;
|
||||
y += (a[1] + b[1]) * c;
|
||||
}
|
||||
|
||||
return k *= 3, [x / k, y / k];
|
||||
};
|
||||
|
||||
// Returns the 2D cross product of AB and AC vectors, i.e., the z-component of
|
||||
// the 3D cross product in a quadrant I Cartesian coordinate system (+x is
|
||||
// right, +y is up). Returns a positive value if ABC is counter-clockwise,
|
||||
// negative if clockwise, and zero if the points are collinear.
|
||||
var cross = function(a, b, c) {
|
||||
return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
|
||||
};
|
||||
|
||||
function lexicographicOrder(a, b) {
|
||||
return a[0] - b[0] || a[1] - b[1];
|
||||
}
|
||||
|
||||
// Computes the upper convex hull per the monotone chain algorithm.
|
||||
// Assumes points.length >= 3, is sorted by x, unique in y.
|
||||
// Returns an array of indices into points in left-to-right order.
|
||||
function computeUpperHullIndexes(points) {
|
||||
var n = points.length,
|
||||
indexes = [0, 1],
|
||||
size = 2;
|
||||
|
||||
for (var i = 2; i < n; ++i) {
|
||||
while (size > 1 && cross(points[indexes[size - 2]], points[indexes[size - 1]], points[i]) <= 0) --size;
|
||||
indexes[size++] = i;
|
||||
}
|
||||
|
||||
return indexes.slice(0, size); // remove popped points
|
||||
}
|
||||
|
||||
var hull = function(points) {
|
||||
if ((n = points.length) < 3) return null;
|
||||
|
||||
var i,
|
||||
n,
|
||||
sortedPoints = new Array(n),
|
||||
flippedPoints = new Array(n);
|
||||
|
||||
for (i = 0; i < n; ++i) sortedPoints[i] = [+points[i][0], +points[i][1], i];
|
||||
sortedPoints.sort(lexicographicOrder);
|
||||
for (i = 0; i < n; ++i) flippedPoints[i] = [sortedPoints[i][0], -sortedPoints[i][1]];
|
||||
|
||||
var upperIndexes = computeUpperHullIndexes(sortedPoints),
|
||||
lowerIndexes = computeUpperHullIndexes(flippedPoints);
|
||||
|
||||
// Construct the hull polygon, removing possible duplicate endpoints.
|
||||
var skipLeft = lowerIndexes[0] === upperIndexes[0],
|
||||
skipRight = lowerIndexes[lowerIndexes.length - 1] === upperIndexes[upperIndexes.length - 1],
|
||||
hull = [];
|
||||
|
||||
// Add upper hull in right-to-l order.
|
||||
// Then add lower hull in left-to-right order.
|
||||
for (i = upperIndexes.length - 1; i >= 0; --i) hull.push(points[sortedPoints[upperIndexes[i]][2]]);
|
||||
for (i = +skipLeft; i < lowerIndexes.length - skipRight; ++i) hull.push(points[sortedPoints[lowerIndexes[i]][2]]);
|
||||
|
||||
return hull;
|
||||
};
|
||||
|
||||
var contains = function(polygon, point) {
|
||||
var n = polygon.length,
|
||||
p = polygon[n - 1],
|
||||
x = point[0], y = point[1],
|
||||
x0 = p[0], y0 = p[1],
|
||||
x1, y1,
|
||||
inside = false;
|
||||
|
||||
for (var i = 0; i < n; ++i) {
|
||||
p = polygon[i], x1 = p[0], y1 = p[1];
|
||||
if (((y1 > y) !== (y0 > y)) && (x < (x0 - x1) * (y - y1) / (y0 - y1) + x1)) inside = !inside;
|
||||
x0 = x1, y0 = y1;
|
||||
}
|
||||
|
||||
return inside;
|
||||
};
|
||||
|
||||
var length = function(polygon) {
|
||||
var i = -1,
|
||||
n = polygon.length,
|
||||
b = polygon[n - 1],
|
||||
xa,
|
||||
ya,
|
||||
xb = b[0],
|
||||
yb = b[1],
|
||||
perimeter = 0;
|
||||
|
||||
while (++i < n) {
|
||||
xa = xb;
|
||||
ya = yb;
|
||||
b = polygon[i];
|
||||
xb = b[0];
|
||||
yb = b[1];
|
||||
xa -= xb;
|
||||
ya -= yb;
|
||||
perimeter += Math.sqrt(xa * xa + ya * ya);
|
||||
}
|
||||
|
||||
return perimeter;
|
||||
};
|
||||
|
||||
exports.polygonArea = area;
|
||||
exports.polygonCentroid = centroid;
|
||||
exports.polygonHull = hull;
|
||||
exports.polygonContains = contains;
|
||||
exports.polygonLength = length;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
2
node_modules/d3-polygon/build/d3-polygon.min.js
generated
vendored
Normal file
2
node_modules/d3-polygon/build/d3-polygon.min.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// https://d3js.org/d3-polygon/ Version 1.0.3. Copyright 2017 Mike Bostock.
|
||||
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(n.d3=n.d3||{})}(this,function(n){"use strict";function r(n,r){return n[0]-r[0]||n[1]-r[1]}function e(n){for(var r=n.length,e=[0,1],t=2,o=2;o<r;++o){for(;t>1&&f(n[e[t-2]],n[e[t-1]],n[o])<=0;)--t;e[t++]=o}return e.slice(0,t)}var t=function(n){for(var r,e=-1,t=n.length,o=n[t-1],f=0;++e<t;)r=o,o=n[e],f+=r[1]*o[0]-r[0]*o[1];return f/2},o=function(n){for(var r,e,t=-1,o=n.length,f=0,u=0,l=n[o-1],i=0;++t<o;)r=l,l=n[t],i+=e=r[0]*l[1]-l[0]*r[1],f+=(r[0]+l[0])*e,u+=(r[1]+l[1])*e;return i*=3,[f/i,u/i]},f=function(n,r,e){return(r[0]-n[0])*(e[1]-n[1])-(r[1]-n[1])*(e[0]-n[0])},u=function(n){if((o=n.length)<3)return null;var t,o,f=new Array(o),u=new Array(o);for(t=0;t<o;++t)f[t]=[+n[t][0],+n[t][1],t];for(f.sort(r),t=0;t<o;++t)u[t]=[f[t][0],-f[t][1]];var l=e(f),i=e(u),g=i[0]===l[0],a=i[i.length-1]===l[l.length-1],c=[];for(t=l.length-1;t>=0;--t)c.push(n[f[l[t]][2]]);for(t=+g;t<i.length-a;++t)c.push(n[f[i[t]][2]]);return c},l=function(n,r){for(var e,t,o=n.length,f=n[o-1],u=r[0],l=r[1],i=f[0],g=f[1],a=!1,c=0;c<o;++c)f=n[c],e=f[0],t=f[1],t>l!=g>l&&u<(i-e)*(l-t)/(g-t)+e&&(a=!a),i=e,g=t;return a},i=function(n){for(var r,e,t=-1,o=n.length,f=n[o-1],u=f[0],l=f[1],i=0;++t<o;)r=u,e=l,f=n[t],u=f[0],l=f[1],r-=u,e-=l,i+=Math.sqrt(r*r+e*e);return i};n.polygonArea=t,n.polygonCentroid=o,n.polygonHull=u,n.polygonContains=l,n.polygonLength=i,Object.defineProperty(n,"__esModule",{value:!0})});
|
||||
BIN
node_modules/d3-polygon/img/hull.png
generated
vendored
Normal file
BIN
node_modules/d3-polygon/img/hull.png
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
5
node_modules/d3-polygon/index.js
generated
vendored
Normal file
5
node_modules/d3-polygon/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export {default as polygonArea} from "./src/area";
|
||||
export {default as polygonCentroid} from "./src/centroid";
|
||||
export {default as polygonHull} from "./src/hull";
|
||||
export {default as polygonContains} from "./src/contains";
|
||||
export {default as polygonLength} from "./src/length";
|
||||
25
node_modules/d3-polygon/package.json
generated
vendored
Normal file
25
node_modules/d3-polygon/package.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "d3-polygon",
|
||||
"version": "1.0.3",
|
||||
"description": "Operations for two-dimensional polygons.",
|
||||
"homepage": "https://d3js.org/d3-polygon/",
|
||||
"license": "BSD-3-Clause",
|
||||
"author": {
|
||||
"name": "Mike Bostock",
|
||||
"url": "http://bost.ocks.org/mike"
|
||||
},
|
||||
"main": "build/d3-polygon.js",
|
||||
"module": "index",
|
||||
"jsnext:main": "index",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/d3/d3-polygon.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "3",
|
||||
"package-preamble": "0.0",
|
||||
"rollup": "0.41",
|
||||
"tape": "4",
|
||||
"uglify-js": "^2.8.11"
|
||||
}
|
||||
}
|
||||
15
node_modules/d3-polygon/src/area.js
generated
vendored
Normal file
15
node_modules/d3-polygon/src/area.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
export default function(polygon) {
|
||||
var i = -1,
|
||||
n = polygon.length,
|
||||
a,
|
||||
b = polygon[n - 1],
|
||||
area = 0;
|
||||
|
||||
while (++i < n) {
|
||||
a = b;
|
||||
b = polygon[i];
|
||||
area += a[1] * b[0] - a[0] * b[1];
|
||||
}
|
||||
|
||||
return area / 2;
|
||||
}
|
||||
20
node_modules/d3-polygon/src/centroid.js
generated
vendored
Normal file
20
node_modules/d3-polygon/src/centroid.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
export default function(polygon) {
|
||||
var i = -1,
|
||||
n = polygon.length,
|
||||
x = 0,
|
||||
y = 0,
|
||||
a,
|
||||
b = polygon[n - 1],
|
||||
c,
|
||||
k = 0;
|
||||
|
||||
while (++i < n) {
|
||||
a = b;
|
||||
b = polygon[i];
|
||||
k += c = a[0] * b[1] - b[0] * a[1];
|
||||
x += (a[0] + b[0]) * c;
|
||||
y += (a[1] + b[1]) * c;
|
||||
}
|
||||
|
||||
return k *= 3, [x / k, y / k];
|
||||
}
|
||||
16
node_modules/d3-polygon/src/contains.js
generated
vendored
Normal file
16
node_modules/d3-polygon/src/contains.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
export default function(polygon, point) {
|
||||
var n = polygon.length,
|
||||
p = polygon[n - 1],
|
||||
x = point[0], y = point[1],
|
||||
x0 = p[0], y0 = p[1],
|
||||
x1, y1,
|
||||
inside = false;
|
||||
|
||||
for (var i = 0; i < n; ++i) {
|
||||
p = polygon[i], x1 = p[0], y1 = p[1];
|
||||
if (((y1 > y) !== (y0 > y)) && (x < (x0 - x1) * (y - y1) / (y0 - y1) + x1)) inside = !inside;
|
||||
x0 = x1, y0 = y1;
|
||||
}
|
||||
|
||||
return inside;
|
||||
}
|
||||
7
node_modules/d3-polygon/src/cross.js
generated
vendored
Normal file
7
node_modules/d3-polygon/src/cross.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
// Returns the 2D cross product of AB and AC vectors, i.e., the z-component of
|
||||
// the 3D cross product in a quadrant I Cartesian coordinate system (+x is
|
||||
// right, +y is up). Returns a positive value if ABC is counter-clockwise,
|
||||
// negative if clockwise, and zero if the points are collinear.
|
||||
export default function(a, b, c) {
|
||||
return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
|
||||
}
|
||||
49
node_modules/d3-polygon/src/hull.js
generated
vendored
Normal file
49
node_modules/d3-polygon/src/hull.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import cross from "./cross";
|
||||
|
||||
function lexicographicOrder(a, b) {
|
||||
return a[0] - b[0] || a[1] - b[1];
|
||||
}
|
||||
|
||||
// Computes the upper convex hull per the monotone chain algorithm.
|
||||
// Assumes points.length >= 3, is sorted by x, unique in y.
|
||||
// Returns an array of indices into points in left-to-right order.
|
||||
function computeUpperHullIndexes(points) {
|
||||
var n = points.length,
|
||||
indexes = [0, 1],
|
||||
size = 2;
|
||||
|
||||
for (var i = 2; i < n; ++i) {
|
||||
while (size > 1 && cross(points[indexes[size - 2]], points[indexes[size - 1]], points[i]) <= 0) --size;
|
||||
indexes[size++] = i;
|
||||
}
|
||||
|
||||
return indexes.slice(0, size); // remove popped points
|
||||
}
|
||||
|
||||
export default function(points) {
|
||||
if ((n = points.length) < 3) return null;
|
||||
|
||||
var i,
|
||||
n,
|
||||
sortedPoints = new Array(n),
|
||||
flippedPoints = new Array(n);
|
||||
|
||||
for (i = 0; i < n; ++i) sortedPoints[i] = [+points[i][0], +points[i][1], i];
|
||||
sortedPoints.sort(lexicographicOrder);
|
||||
for (i = 0; i < n; ++i) flippedPoints[i] = [sortedPoints[i][0], -sortedPoints[i][1]];
|
||||
|
||||
var upperIndexes = computeUpperHullIndexes(sortedPoints),
|
||||
lowerIndexes = computeUpperHullIndexes(flippedPoints);
|
||||
|
||||
// Construct the hull polygon, removing possible duplicate endpoints.
|
||||
var skipLeft = lowerIndexes[0] === upperIndexes[0],
|
||||
skipRight = lowerIndexes[lowerIndexes.length - 1] === upperIndexes[upperIndexes.length - 1],
|
||||
hull = [];
|
||||
|
||||
// Add upper hull in right-to-l order.
|
||||
// Then add lower hull in left-to-right order.
|
||||
for (i = upperIndexes.length - 1; i >= 0; --i) hull.push(points[sortedPoints[upperIndexes[i]][2]]);
|
||||
for (i = +skipLeft; i < lowerIndexes.length - skipRight; ++i) hull.push(points[sortedPoints[lowerIndexes[i]][2]]);
|
||||
|
||||
return hull;
|
||||
}
|
||||
23
node_modules/d3-polygon/src/length.js
generated
vendored
Normal file
23
node_modules/d3-polygon/src/length.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
export default function(polygon) {
|
||||
var i = -1,
|
||||
n = polygon.length,
|
||||
b = polygon[n - 1],
|
||||
xa,
|
||||
ya,
|
||||
xb = b[0],
|
||||
yb = b[1],
|
||||
perimeter = 0;
|
||||
|
||||
while (++i < n) {
|
||||
xa = xb;
|
||||
ya = yb;
|
||||
b = polygon[i];
|
||||
xb = b[0];
|
||||
yb = b[1];
|
||||
xa -= xb;
|
||||
ya -= yb;
|
||||
perimeter += Math.sqrt(xa * xa + ya * ya);
|
||||
}
|
||||
|
||||
return perimeter;
|
||||
}
|
||||
Reference in New Issue
Block a user