d3-geo-voronoi
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,2 +0,2 @@ | ||
// https://github.com/Fil/d3-geo-voronoi Version 1.0.0. Copyright 2018 Philippe Riviere. | ||
// https://github.com/Fil/d3-geo-voronoi Version 1.0.1. Copyright 2018 Philippe Riviere. | ||
(function (global, factory) { | ||
@@ -9,4 +9,4 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-delaunay'), require('d3-geo'), require('d3-array')) : | ||
var pi = Math.PI; | ||
var halfPi = pi / 2; | ||
var tau = pi * 2; | ||
@@ -19,3 +19,3 @@ | ||
var atan2 = Math.atan2; | ||
var cos = Math.cos; | ||
@@ -26,2 +26,4 @@ | ||
var max = Math.max; | ||
var min = Math.min; | ||
@@ -36,2 +38,9 @@ var sin = Math.sin; | ||
function asin(x) { | ||
return x > 1 ? halfPi : x < -1 ? -halfPi : Math.asin(x); | ||
} | ||
function cartesianDot(a, b) { | ||
@@ -76,4 +85,4 @@ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; | ||
return [ | ||
Math.atan2(cartesian[1], cartesian[0]) * degrees, | ||
Math.asin(Math.max(-1, Math.min(1, cartesian[2]))) * degrees | ||
atan2(cartesian[1], cartesian[0]) * degrees, | ||
asin(max(-1, min(1, cartesian[2]))) * degrees | ||
]; | ||
@@ -86,4 +95,4 @@ } | ||
phi = coordinates[1] * radians, | ||
cosphi = Math.cos(phi); | ||
return [cosphi * Math.cos(lambda), cosphi * Math.sin(lambda), Math.sin(phi)]; | ||
cosphi = cos(phi); | ||
return [cosphi * cos(lambda), cosphi * sin(lambda), sin(phi)]; | ||
} | ||
@@ -558,2 +567,13 @@ | ||
v.mesh = function(data) { | ||
if (data !== undefined) { | ||
v(data); | ||
} | ||
if (!v.delaunay) return false; | ||
return { | ||
type: "MultiLineString", | ||
coordinates: v.delaunay.edges.map(e => [v.points[e[0]], v.points[e[1]]]) | ||
}; | ||
}; | ||
v._found = undefined; | ||
@@ -560,0 +580,0 @@ v.find = function(x, y, radius) { |
@@ -1,1 +0,1 @@ | ||
(function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-delaunay"),require("d3-geo"),require("d3-array")):"function"==typeof define&&define.amd?define(["exports","d3-delaunay","d3-geo","d3-array"],t):t(e.d3=e.d3||{},e.d3,e.d3,e.d3)})(this,function(e,t,n,o){"use strict";var r=Math.PI,a=2*r,u=180/r,i=r/180,l=Math.cos,s=Math.sin,c=Math.sign||function(e){return e>0?1:e<0?-1:0},f=Math.sqrt;function p(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function d(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function h(e){var t=f(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);return[e[0]/t,e[1]/t,e[2]/t]}function g(e){return[Math.atan2(e[1],e[0])*u,Math.asin(Math.max(-1,Math.min(1,e[2])))*u]}function y(e){var t=e[0]*i,n=e[1]*i,o=Math.cos(n);return[o*Math.cos(t),o*Math.sin(t),Math.sin(n)]}function m(e){const u=function(e){if(e.length<2)return{};const o=n.geoRotation(e[0]),a=n.geoStereographic().translate([0,0]).scale(1).rotate(o.invert([180,0])),u=[0];let i=1;for(let t=1,n=(e=e.map(a)).length;t<n;t++){let n=e[t][0]*e[t][0]+e[t][1]*e[t][1];isNaN(n)&&u.push(t),n>i&&(i=n)}const c=1e6*f(i);u.forEach((t,n)=>e[n]=[c/2,0]);for(let t=0;t<4;t++)e.push([c*l(t/2*r),c*s(t/2*r)]);const p=t.Delaunay.from(e);return p.projection=a,p}(e),i=function(e,t){const n=[],r=e.halfedges,a=e.triangles,u={};if(!r)return n;for(let e=0,i=r.length;e<i;++e){const i=r[e];if(i<e)continue;let[l,s]=o.extent([a[e],a[i]]);s>=t&&l<t&&(s=l,l=0),s>0&&s<t&&(l>0||!u[s]++&&(u[s]=!0))&&n.push([l,s])}return n}(u,e.length),c=function(e,t){if(!e.triangles)return[];const n=e.triangles.slice().map(e=>e>=t?0:e),o=[];for(let e=0,t=n.length/3;e<t;e++){const t=n[3*e],r=n[3*e+1],a=n[3*e+2];t!==r&&r!==a&&a!==t&&o.push([t,a,r])}return o}(u,e.length),m=function(e,t){const n=[];e.forEach((e,t)=>{for(let t=0;t<3;t++){const o=e[t],r=e[(t+1)%3];n[o]=n[o]||[],n[o].push(r)}}),0===e.length&&(2===t?(n[0]=[1],n[1]=[0]):1===t&&(n[0]=[]));return n}(c,e.length),v=function(e,t){return function(o,r,a){let u,i,l=0;void 0===a&&(a=0);do{u=a,a=null,i=n.geoDistance([o,r],t[u]),e[u].forEach(e=>{let u=n.geoDistance([o,r],t[e]);if(u<i)return i=u,a=e,void(l=e)})}while(null!==a);return l}}(m,e),M=function(e,t){return e.map(e=>{const n=e.map(e=>t[e]).map(y),o=d(d(p(n[1],n[0]),p(n[2],n[1])),p(n[0],n[2]));return g(h(o))})}(c,e),{polygons:b,centers:j}=function(e,t,n){const o=[],r=e.slice();if(0===t.length){if(n.length<2)return{polygons:o,centers:r};if(2===n.length){const e=y(n[0]),t=y(n[1]),u=h(d(e,t)),i=h(p(e,t)),l=p(u,i),s=[u,p(u,l),p(p(u,l),l),p(p(p(u,l),l),l)].map(g).map(a);return o.push(s),o.push(s.slice().reverse()),{polygons:o,centers:r}}}function a(e){let n=-1;return r.slice(t.length,1/0).forEach((o,r)=>{o[0]===e[0]&&o[1]===e[1]&&(n=r+t.length)}),n<0&&(n=r.length,r.push(e)),n}return t.forEach((e,t)=>{for(let n=0;n<3;n++){const r=e[n],a=e[(n+1)%3],u=e[(n+2)%3];o[r]=o[r]||[],o[r].push([a,u,t,[r,a,u]])}}),{polygons:o.map(e=>{const t=[e[0][2]];let o=e[0][1];for(let n=1;n<e.length;n++)for(let n=0;n<e.length;n++)if(e[n][0]==o){o=e[n][1],t.push(e[n][2]);break}if(t.length>2)return t;if(2==t.length){const o=_(n[e[0][3][0]],n[e[0][3][1]],r[t[0]]),u=_(n[e[0][3][2]],n[e[0][3][0]],r[t[0]]),i=a(o),l=a(u);return[t[0],l,t[1],i]}console&&console.warn({here:"unreachable",poly:e})}),centers:r}}(M,c,e);return{delaunay:u,edges:i,triangles:c,centers:j,neighbors:m,polygons:b,mesh:function(e){const t=[];return e.forEach(e=>{if(!e)return;let n=e[e.length-1];for(let o of e)o>n&&t.push([n,o]),n=o}),t}(b),hull:function(e,t){const o={},r=[];e.map(e=>{const r={type:"Polygon",coordinates:[[t[e[0]],t[e[1]],t[e[2]],t[e[0]]]]};if(!(n.geoArea(r)>a))for(let t=0;t<3;t++){let n=[e[t],e[(t+1)%3]],r=`${n[1]}-${n[0]}`;o[r]?delete o[r]:o[n.join("-")]=!0}});const u={};let i;if(Object.keys(o).forEach(e=>{e=e.split("-").map(Number),u[e[0]]=e[1],i=e[0]}),void 0===i)return r;let l=i;do{r.push(l),l=u[l]}while(l!==i);return r}(c,e),urquhart:function(e,t){return function(n){const r={},a={};return e.forEach((e,t)=>{const o=e.join("-");r[o]=n[t],a[o]=!0}),t.forEach(e=>{let t=0,n=-1;for(var u=0;u<3;u++){let a=o.extent([e[u],e[(u+1)%3]]).join("-");r[a]>t&&(t=r[a],n=a)}a[n]=!1}),e.map(e=>a[e.join("-")])}}(i,c),find:v}}function _(e,t,n){e=y(e),t=y(t),n=y(n);const o=c(function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}(p(t,e),n));return g(h(d(e,t)).map(e=>o*e))}e.geoDelaunay=m,e.geoVoronoi=function(e){const t=function(e){return t.delaunay=null,t._data=e,"object"==typeof t._data&&"FeatureCollection"===t._data.type&&(t._data=t._data.features),"object"==typeof t._data&&(t.points=t._data.map(e=>[t._vx(e),t._vy(e)]),t.delaunay=m(t.points)),t};return t._vx=function(e){return"object"==typeof e&&"type"in e?n.geoCentroid(e)[0]:0 in e?e[0]:void 0},t._vy=function(e){return"object"==typeof e&&"type"in e?n.geoCentroid(e)[1]:1 in e?e[1]:void 0},t.x=function(e){return e?(t._vx=e,t):t._vx},t.y=function(e){return e?(t._vy=e,t):t._vy},t.polygons=function(e){return void 0!==e&&t(e),!!t.delaunay&&(0===t._data.length?null:1===t._data.length?{type:"Sphere"}:{type:"FeatureCollection",features:t.delaunay.polygons.map((e,n)=>({type:"Feature",geometry:e?{type:"Polygon",coordinates:[[...e,e[0]].map(e=>t.delaunay.centers[e])]}:null,properties:{site:t._data[n],sitecoordinates:t.points[n],neighbours:t.delaunay.neighbors[n]}}))})},t.triangles=function(e){return void 0!==e&&t(e),!!t.delaunay&&{type:"FeatureCollection",features:t.delaunay.triangles.map((e,n)=>({type:"Feature",properties:{circumcenter:t.delaunay.centers[n]},geometry:{type:"Polygon",coordinates:[[t.points[e[0]],t.points[e[1]],t.points[e[2]],t.points[e[0]]]]}})).filter(e=>n.geoArea(e)<=a)}},t.links=function(e){if(void 0!==e&&t(e),!t.delaunay)return!1;const o=t.delaunay.edges.map(e=>n.geoDistance(t.points[e[0]],t.points[e[1]])),r=t.delaunay.urquhart(o);return{type:"FeatureCollection",features:t.delaunay.edges.map((e,n)=>({type:"Feature",properties:{source:t._data[e[0]],target:t._data[e[1]],length:o[n],urquhart:!!r[n]},geometry:{type:"LineString",coordinates:[t.points[e[0]],t.points[e[1]]]}}))}},t._found=void 0,t.find=function(e,o,r){if(t._found=t.delaunay.find(e,o,t._found),!r||n.geoDistance([e,o],t.points[t._found])<r)return t._found},t.hull=function(e){void 0!==e&&t(e);const n=t.delaunay.hull,o=t.points;return 0===n.length?null:{type:"Polygon",coordinates:[[...n.map(e=>o[e]),o[n[0]]]]}},e?t(e):t},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
(function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-delaunay"),require("d3-geo"),require("d3-array")):"function"==typeof define&&define.amd?define(["exports","d3-delaunay","d3-geo","d3-array"],t):t(e.d3=e.d3||{},e.d3,e.d3,e.d3)})(this,function(e,t,n,o){"use strict";var r=Math.PI,a=r/2,u=2*r,i=180/r,l=r/180,s=Math.atan2,c=Math.cos,f=Math.max,p=Math.min,d=Math.sin,h=Math.sign||function(e){return e>0?1:e<0?-1:0},g=Math.sqrt;function y(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function m(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function v(e){var t=g(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);return[e[0]/t,e[1]/t,e[2]/t]}function _(e){return[s(e[1],e[0])*i,(t=f(-1,p(1,e[2])),(t>1?a:t<-1?-a:Math.asin(t))*i)];var t}function b(e){var t=e[0]*l,n=e[1]*l,o=c(n);return[o*c(t),o*d(t),d(n)]}function j(e){const a=function(e){if(e.length<2)return{};const o=n.geoRotation(e[0]),a=n.geoStereographic().translate([0,0]).scale(1).rotate(o.invert([180,0])),u=[0];let i=1;for(let t=1,n=(e=e.map(a)).length;t<n;t++){let n=e[t][0]*e[t][0]+e[t][1]*e[t][1];isNaN(n)&&u.push(t),n>i&&(i=n)}const l=1e6*g(i);u.forEach((t,n)=>e[n]=[l/2,0]);for(let t=0;t<4;t++)e.push([l*c(t/2*r),l*d(t/2*r)]);const s=t.Delaunay.from(e);return s.projection=a,s}(e),i=function(e,t){const n=[],r=e.halfedges,a=e.triangles,u={};if(!r)return n;for(let e=0,i=r.length;e<i;++e){const i=r[e];if(i<e)continue;let[l,s]=o.extent([a[e],a[i]]);s>=t&&l<t&&(s=l,l=0),s>0&&s<t&&(l>0||!u[s]++&&(u[s]=!0))&&n.push([l,s])}return n}(a,e.length),l=function(e,t){if(!e.triangles)return[];const n=e.triangles.slice().map(e=>e>=t?0:e),o=[];for(let e=0,t=n.length/3;e<t;e++){const t=n[3*e],r=n[3*e+1],a=n[3*e+2];t!==r&&r!==a&&a!==t&&o.push([t,a,r])}return o}(a,e.length),s=function(e,t){const n=[];e.forEach((e,t)=>{for(let t=0;t<3;t++){const o=e[t],r=e[(t+1)%3];n[o]=n[o]||[],n[o].push(r)}}),0===e.length&&(2===t?(n[0]=[1],n[1]=[0]):1===t&&(n[0]=[]));return n}(l,e.length),f=function(e,t){return function(o,r,a){let u,i,l=0;void 0===a&&(a=0);do{u=a,a=null,i=n.geoDistance([o,r],t[u]),e[u].forEach(e=>{let u=n.geoDistance([o,r],t[e]);if(u<i)return i=u,a=e,void(l=e)})}while(null!==a);return l}}(s,e),p=function(e,t){return e.map(e=>{const n=e.map(e=>t[e]).map(b),o=m(m(y(n[1],n[0]),y(n[2],n[1])),y(n[0],n[2]));return _(v(o))})}(l,e),{polygons:h,centers:j}=function(e,t,n){const o=[],r=e.slice();if(0===t.length){if(n.length<2)return{polygons:o,centers:r};if(2===n.length){const e=b(n[0]),t=b(n[1]),u=v(m(e,t)),i=v(y(e,t)),l=y(u,i),s=[u,y(u,l),y(y(u,l),l),y(y(y(u,l),l),l)].map(_).map(a);return o.push(s),o.push(s.slice().reverse()),{polygons:o,centers:r}}}function a(e){let n=-1;return r.slice(t.length,1/0).forEach((o,r)=>{o[0]===e[0]&&o[1]===e[1]&&(n=r+t.length)}),n<0&&(n=r.length,r.push(e)),n}return t.forEach((e,t)=>{for(let n=0;n<3;n++){const r=e[n],a=e[(n+1)%3],u=e[(n+2)%3];o[r]=o[r]||[],o[r].push([a,u,t,[r,a,u]])}}),{polygons:o.map(e=>{const t=[e[0][2]];let o=e[0][1];for(let n=1;n<e.length;n++)for(let n=0;n<e.length;n++)if(e[n][0]==o){o=e[n][1],t.push(e[n][2]);break}if(t.length>2)return t;if(2==t.length){const o=x(n[e[0][3][0]],n[e[0][3][1]],r[t[0]]),u=x(n[e[0][3][2]],n[e[0][3][0]],r[t[0]]),i=a(o),l=a(u);return[t[0],l,t[1],i]}console&&console.warn({here:"unreachable",poly:e})}),centers:r}}(p,l,e);return{delaunay:a,edges:i,triangles:l,centers:j,neighbors:s,polygons:h,mesh:function(e){const t=[];return e.forEach(e=>{if(!e)return;let n=e[e.length-1];for(let o of e)o>n&&t.push([n,o]),n=o}),t}(h),hull:function(e,t){const o={},r=[];e.map(e=>{const r={type:"Polygon",coordinates:[[t[e[0]],t[e[1]],t[e[2]],t[e[0]]]]};if(!(n.geoArea(r)>u))for(let t=0;t<3;t++){let n=[e[t],e[(t+1)%3]],r=`${n[1]}-${n[0]}`;o[r]?delete o[r]:o[n.join("-")]=!0}});const a={};let i;if(Object.keys(o).forEach(e=>{e=e.split("-").map(Number),a[e[0]]=e[1],i=e[0]}),void 0===i)return r;let l=i;do{r.push(l),l=a[l]}while(l!==i);return r}(l,e),urquhart:function(e,t){return function(n){const r={},a={};return e.forEach((e,t)=>{const o=e.join("-");r[o]=n[t],a[o]=!0}),t.forEach(e=>{let t=0,n=-1;for(var u=0;u<3;u++){let a=o.extent([e[u],e[(u+1)%3]]).join("-");r[a]>t&&(t=r[a],n=a)}a[n]=!1}),e.map(e=>a[e.join("-")])}}(i,l),find:f}}function x(e,t,n){e=b(e),t=b(t),n=b(n);const o=h(function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}(y(t,e),n));return _(v(m(e,t)).map(e=>o*e))}e.geoDelaunay=j,e.geoVoronoi=function(e){const t=function(e){return t.delaunay=null,t._data=e,"object"==typeof t._data&&"FeatureCollection"===t._data.type&&(t._data=t._data.features),"object"==typeof t._data&&(t.points=t._data.map(e=>[t._vx(e),t._vy(e)]),t.delaunay=j(t.points)),t};return t._vx=function(e){return"object"==typeof e&&"type"in e?n.geoCentroid(e)[0]:0 in e?e[0]:void 0},t._vy=function(e){return"object"==typeof e&&"type"in e?n.geoCentroid(e)[1]:1 in e?e[1]:void 0},t.x=function(e){return e?(t._vx=e,t):t._vx},t.y=function(e){return e?(t._vy=e,t):t._vy},t.polygons=function(e){return void 0!==e&&t(e),!!t.delaunay&&(0===t._data.length?null:1===t._data.length?{type:"Sphere"}:{type:"FeatureCollection",features:t.delaunay.polygons.map((e,n)=>({type:"Feature",geometry:e?{type:"Polygon",coordinates:[[...e,e[0]].map(e=>t.delaunay.centers[e])]}:null,properties:{site:t._data[n],sitecoordinates:t.points[n],neighbours:t.delaunay.neighbors[n]}}))})},t.triangles=function(e){return void 0!==e&&t(e),!!t.delaunay&&{type:"FeatureCollection",features:t.delaunay.triangles.map((e,n)=>({type:"Feature",properties:{circumcenter:t.delaunay.centers[n]},geometry:{type:"Polygon",coordinates:[[t.points[e[0]],t.points[e[1]],t.points[e[2]],t.points[e[0]]]]}})).filter(e=>n.geoArea(e)<=u)}},t.links=function(e){if(void 0!==e&&t(e),!t.delaunay)return!1;const o=t.delaunay.edges.map(e=>n.geoDistance(t.points[e[0]],t.points[e[1]])),r=t.delaunay.urquhart(o);return{type:"FeatureCollection",features:t.delaunay.edges.map((e,n)=>({type:"Feature",properties:{source:t._data[e[0]],target:t._data[e[1]],length:o[n],urquhart:!!r[n]},geometry:{type:"LineString",coordinates:[t.points[e[0]],t.points[e[1]]]}}))}},t.mesh=function(e){return void 0!==e&&t(e),!!t.delaunay&&{type:"MultiLineString",coordinates:t.delaunay.edges.map(e=>[t.points[e[0]],t.points[e[1]]])}},t._found=void 0,t.find=function(e,o,r){if(t._found=t.delaunay.find(e,o,t._found),!r||n.geoDistance([e,o],t.points[t._found])<r)return t._found},t.hull=function(e){void 0!==e&&t(e);const n=t.delaunay.hull,o=t.points;return 0===n.length?null:{type:"Polygon",coordinates:[[...n.map(e=>o[e]),o[n[0]]]]}},e?t(e):t},Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "d3-geo-voronoi", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Spherical Voronoi Diagram and Delaunay Triangulation", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
# d3-geo-voronoi | ||
This module adapts d3-delaunay for spherical data. Given a set of objects in spherical coordinates, it computes their Delaunay triangulation and its dual, the Voronoi diagram. | ||
This module adapts [d3-delaunay](https://github.com/d3/d3-delaunay) for spherical data. Given a set of objects in spherical coordinates, it computes their Delaunay triangulation and its dual, the Voronoi diagram. | ||
@@ -72,2 +72,6 @@ In addition, it offers convenience methods to extract the convex hull, the Urquhart graph, the circumcenters of the Delaunay triangles, and to find the cell that contains any given point on the sphere. | ||
<a href="#geo_voronoi_mesh" name="geo_voronoi_mesh">#</a> <i>voronoi</i>.<b>mesh</b>(<i>[data]</i>) | ||
Returns the Voronoi tessellation of the data as a GeoJSON mesh (MultiLineString). | ||
<a href="#geo_voronoi_triangles" name="geo_voronoi_triangles">#</a> <i>voronoi</i>.<b>triangles</b>(<i>[data]</i>) | ||
@@ -143,6 +147,8 @@ | ||
&lk;script src="https://unpkg.com/d3-delaunay@4></script> | ||
&lk;script src="https://unpkg.com/d3-geo-voronoi@1"></script> | ||
``` | ||
<script src="https://unpkg.com/d3-delaunay@4></script> | ||
<script src="https://unpkg.com/d3-geo-voronoi@1"></script> | ||
``` | ||
To access the previous (slow) version, please use &lk;script src="https://unpkg.com/d3-geo-voronoi@0"></script> | ||
(To access the previous (slow) version, please use `https://unpkg.com/d3-geo-voronoi@0`.) | ||
@@ -152,1 +158,2 @@ | ||
@@ -11,3 +11,3 @@ // | ||
import { extent } from "d3-array"; | ||
import { cos, degrees, pi, radians, sign, sin, sqrt, tau } from "./math.js"; | ||
import { asin, atan2, cos, degrees, max, min, pi, radians, sign, sin, sqrt, tau } from "./math.js"; | ||
import { | ||
@@ -23,4 +23,4 @@ cartesianNormalize as normalize, | ||
return [ | ||
Math.atan2(cartesian[1], cartesian[0]) * degrees, | ||
Math.asin(Math.max(-1, Math.min(1, cartesian[2]))) * degrees | ||
atan2(cartesian[1], cartesian[0]) * degrees, | ||
asin(max(-1, min(1, cartesian[2]))) * degrees | ||
]; | ||
@@ -33,4 +33,4 @@ } | ||
phi = coordinates[1] * radians, | ||
cosphi = Math.cos(phi); | ||
return [cosphi * Math.cos(lambda), cosphi * Math.sin(lambda), Math.sin(phi)]; | ||
cosphi = cos(phi); | ||
return [cosphi * cos(lambda), cosphi * sin(lambda), sin(phi)]; | ||
} | ||
@@ -37,0 +37,0 @@ |
@@ -19,2 +19,4 @@ export var epsilon = 1e-6; | ||
export var log = Math.log; | ||
export var max = Math.max; | ||
export var min = Math.min; | ||
export var pow = Math.pow; | ||
@@ -21,0 +23,0 @@ export var sin = Math.sin; |
@@ -135,2 +135,13 @@ // | ||
v.mesh = function(data) { | ||
if (data !== undefined) { | ||
v(data); | ||
} | ||
if (!v.delaunay) return false; | ||
return { | ||
type: "MultiLineString", | ||
coordinates: v.delaunay.edges.map(e => [v.points[e[0]], v.points[e[1]]]) | ||
}; | ||
}; | ||
v._found = undefined; | ||
@@ -137,0 +148,0 @@ v.find = function(x, y, radius) { |
9434901
14973
157