![](/assets/images/project_default_logo.png)
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("d3-array"),require("d3-polygon")):"function"==typeof define&&define.amd?define(["exports","d3-array","d3-polygon"],i):i(t.d3=t.d3||{},t.d3,t.d3)}(this,function(t,i,n){"use strict";function e(t){return t<=C&&t>=-C}function s(t,i){return t.x*i.x+t.y*i.y+t.z*i.z}function o(t,i){return e(t.x*i.y-t.y*i.x)&&e(t.y*i.z-t.z*i.y)&&e(t.z*i.x-t.x*i.z)}function r(t){var i,n,e,s,o,r,u,c;if(e=t[t.length-2],s=t[t.length-1],o=t[0],r=h(e,s),u=h(s,o),n=l(r,u),i=Math.sign(n),e=s,s=o,o=t[1],r=u,u=h(s,o),n=l(r,u),Math.sign(n)===i){for(c=2;c<t.length-1;c++)if(e=s,s=o,o=t[c],r=u,u=h(s,o),n=l(r,u),Math.sign(n)!==i)return;return i}}function h(t,i){return[i[0]-t[0],i[1]-t[1]]}function l(t,i){return t[0]*i[1]-t[1]*i[0]}function u(t,i){this.face=t,this.vert=i,this.nextf=null,this.prevf=null,this.nextv=null,this.prevv=null}function c(t){this.forFace=t,this.head=null}function a(t,i,n,e,s,o){this.x=t,this.y=i,this.weight=C,this.index=0,this.conflicts=new c((!1)),this.neighbours=null,this.nonClippedPolygon=null,this.polygon=null,this.originalObject=null,this.isDummy=!1,void 0!==s&&(this.originalObject=s),void 0!=o&&(this.isDummy=o),null!=e&&(this.weight=e),null!=n?this.z=n:this.z=this.projectZ(this.x,this.y,this.weight)}function f(t){var i=t.verts[0],n=t.verts[1],e=t.verts[2];this.a=i.y*(n.z-e.z)+n.y*(e.z-i.z)+e.y*(i.z-n.z),this.b=i.z*(n.x-e.x)+n.z*(e.x-i.x)+e.z*(i.x-n.x),this.c=i.x*(n.y-e.y)+n.x*(e.y-i.y)+e.x*(i.y-n.y),this.d=-1*(i.x*(n.y*e.z-e.y*n.z)+n.x*(e.y*i.z-i.y*e.z)+e.x*(i.y*n.z-n.y*i.z))}function p(t,i){this.x=t,this.y=i}function d(t,i,n){this.x=t,this.y=i,this.z=n}function v(t,i,n){this.next=null,this.prev=null,this.twin=null,this.orig=t,this.dest=i,this.iFace=n}function g(t){this.message=t,this.stack=(new Error).stack}function y(t,i,n,e){this.conflicts=new c((!0)),this.verts=[t,i,n],this.marked=!1;var s=t.subtract(i).crossproduct(i.subtract(n));this.normal=new d((-s.x),(-s.y),(-s.z)),this.normal.normalize(),this.createEdges(),this.dualPoint=null,void 0!=e&&this.orient(e)}function x(){this.points=[],this.facets=[],this.created=[],this.horizon=[],this.visible=[],this.current=0}function w(t,i){for(var n,e,s,o,r,h,l,u=b(i),c=-1,a=t.length-b(t),f=t[a-1];++c<a;){for(n=i.slice(),i.length=0,o=t[c],r=n[(s=n.length-u)-1],e=-1;++e<s;)h=n[e],z(h,f,o)?(z(r,f,o)||(l=m(r,h,f,o),isFinite(l[0])&&i.push(l)),i.push(h)):z(r,f,o)&&(l=m(r,h,f,o),isFinite(l[0])&&i.push(l)),r=h;u&&i.push(i[0]),f=o}return i}function z(t,i,n){return(n[0]-i[0])*(t[1]-i[1])<(n[1]-i[1])*(t[0]-i[0])}function m(t,i,n,e){var s=t[0],o=n[0],r=i[0]-s,h=e[0]-o,l=t[1],u=n[1],c=i[1]-l,a=e[1]-u,f=(h*(l-u)-a*(s-o))/(a*r-h*c);return[s+f*r,l+f*c]}function b(t){var i=t[0],n=t[t.length-1];return!(i[0]-n[0]||i[1]-n[1])}function k(t){var i=[],n=t,e=t.dest,s=e.originalObject,o=[];do{n=n.twin.prev;var r=n.orig.originalObject;r.isDummy||o.push(r);var h=n.iFace;h.isVisibleFromBelow()&&i.push(h)}while(n!==t);return s.neighbours=o,i}function F(t,i,e){var s=new x;s.clear(),s.init(i,t);for(var o=s.compute(t),r=[],h=[],l=o.length,u=0;u<l;u++){var c=o[u];if(c.isVisibleFromBelow())for(var a=0;a<3;a++){var f=c.edges[a],p=f.dest,d=p.originalObject;if(!h[p.index]){if(h[p.index]=!0,d.isDummy)continue;for(var v=k(f),g=[],y=null,z=null,m=1,b=1,F=0;F<v.length;F++){var P=v[F].getDualPoint(),E=P.x,j=P.y;null!==y&&(m=y-E,b=z-j,m<0&&(m=-m),b<0&&(b=-b)),(m>C||b>C)&&(g.push([E,j]),y=E,z=j)}if(d.nonClippedPolygon=g.reverse(),!d.isDummy&&n.polygonLength(d.nonClippedPolygon)>0){var q=w(e,d.nonClippedPolygon);d.polygon=q,q.site=d,q.length>0&&r.push(q)}}}}return r}function P(){function t(t){var i;return i=t.map(function(t){return new a(s(t),o(t),null,h(t),t,(!1))}),F(i,e(),l)}function e(){var t,i,n,e,s,o,r,h,l,c,f=[],p=[];t=u[0][0],i=u[1][0],n=u[0][1],e=u[1][1],s=i-t,o=e-n,r=t-s,h=i+s,l=n-o,c=e+o,f[0]=[r,l],f[1]=[r,c],f[2]=[h,c],f[3]=[h,l];for(var d=0;d<4;d++)p.push(new a(f[d][0],f[d][1],null,C,new a(f[d][0],f[d][1],null,C,null,(!0)),(!0)));return p}var s=function(t){return t.x},o=function(t){return t.y},h=function(t){return t.weight},l=[[0,0],[0,1],[1,1],[1,0]],u=[[0,0],[1,1]],c=[1,1];return t.x=function(i){return arguments.length?(s=i,t):s},t.y=function(i){return arguments.length?(o=i,t):o},t.weight=function(i){return arguments.length?(h=i,t):h},t.clip=function(e){var s,o,h;return arguments.length?(o=i.extent(e.map(function(t){return t[0]})),h=i.extent(e.map(function(t){return t[1]})),s=r(e),l=void 0===s?n.polygonHull(e):1===s?e.reverse():e,u=[[o[0],h[0]],[o[1],h[1]]],c=[o[1]-o[0],h[1]-h[0]],t):l},t.extent=function(i){return arguments.length?(l=[i[0],[i[0][0],i[1][1]],i[1],[i[1][0],i[0][1]]],u=i,c=[i[1][0]-i[0][0],i[1][1]-i[0][1]],t):u},t.size=function(i){return arguments.length?(l=[[0,0],[0,i[1]],[i[0],i[1]],[i[0],0]],u=[[0,0],i],c=i,t):c},t}var C=1e-10;c.prototype.add=function(t){null===this.head?this.head=t:this.forFace?(this.head.prevv=t,t.nextv=this.head,this.head=t):(this.head.prevf=t,t.nextf=this.head,this.head=t)},c.prototype.isEmpty=function(){return null===this.head},c.prototype.fill=function(t){if(!this.forFace){var i=this.head;do t.push(i.face),i.face.marked=!0,i=i.nextf;while(null!==i)}},c.prototype.removeAll=function(){if(this.forFace){var t=this.head;do null===t.prevf?null===t.nextf?t.vert.conflicts.head=null:(t.nextf.prevf=null,t.vert.conflicts.head=t.nextf):(null!=t.nextf&&(t.nextf.prevf=t.prevf),t.prevf.nextf=t.nextf),t=t.nextv,null!=t&&(t.prevv=null);while(null!=t)}else{var t=this.head;do null==t.prevv?null==t.nextv?t.face.conflicts.head=null:(t.nextv.prevv=null,t.face.conflicts.head=t.nextv):(null!=t.nextv&&(t.nextv.prevv=t.prevv),t.prevv.nextv=t.nextv),t=t.nextf,null!=t&&(t.prevf=null);while(null!=t)}},c.prototype.getVertices=function(){for(var t=[],i=this.head;null!==i;)t.push(i.vert),i=i.nextv;return t},a.prototype.projectZ=function(t,i,n){return t*t+i*i-n},a.prototype.setWeight=function(t){this.weight=t,this.z=this.projectZ(this.x,this.y,this.weight)},a.prototype.subtract=function(t){return new a(t.x-this.x,t.y-this.y,t.z-this.z)},a.prototype.crossproduct=function(t){return new a(this.y*t.z-this.z*t.y,this.z*t.x-this.x*t.z,this.x*t.y-this.y*t.x)},a.prototype.equals=function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z},f.prototype.getNormZPlane=function(){return[-1*(this.a/this.c),-1*(this.b/this.c),-1*(this.d/this.c)]},f.prototype.getDualPointMappedToPlane=function(){var t=this.getNormZPlane(),i=new p(t[0]/2,t[1]/2);return i},d.prototype.negate=function(){this.x*=-1,this.y*=-1,this.z*=-1},d.prototype.normalize=function(){var t=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);t>0&&(this.x/=t,this.y/=t,this.z/=t)},v.prototype.isHorizon=function(){return null!==this.twin&&!this.iFace.marked&&this.twin.iFace.marked},v.prototype.findHorizon=function(t){if(this.isHorizon()){if(t.length>0&&this===t[0])return;t.push(this),this.next.findHorizon(t)}else null!==this.twin&&this.twin.next.findHorizon(t)},v.prototype.isEqual=function(t,i){return this.orig.equals(t)&&this.dest.equals(i)||this.orig.equals(i)&&this.dest.equals(t)},g.prototype.name="d3WeightedVoronoiError",g.prototype=new Error,y.prototype.getDualPoint=function(){if(null==this.dualPoint){var t=new f(this);this.dualPoint=t.getDualPointMappedToPlane()}return this.dualPoint},y.prototype.isVisibleFromBelow=function(){return this.normal.z<-1.4259414393190911e-9},y.prototype.createEdges=function(){this.edges=[],this.edges[0]=new v(this.verts[0],this.verts[1],this),this.edges[1]=new v(this.verts[1],this.verts[2],this),this.edges[2]=new v(this.verts[2],this.verts[0],this),this.edges[0].next=this.edges[1],this.edges[0].prev=this.edges[2],this.edges[1].next=this.edges[2],this.edges[1].prev=this.edges[0],this.edges[2].next=this.edges[0],this.edges[2].prev=this.edges[1]},y.prototype.orient=function(t){if(!(s(this.normal,t)<s(this.normal,this.verts[0]))){var i=this.verts[1];this.verts[1]=this.verts[2],this.verts[2]=i,this.normal.negate(),this.createEdges()}},y.prototype.getEdge=function(t,i){for(var n=0;n<3;n++)if(this.edges[n].isEqual(t,i))return this.edges[n];return null},y.prototype.link=function(t,i,n){if(t instanceof y){var e=t.getEdge(i,n);if(null===e)throw new g("when linking, twin is null");var s=this.getEdge(i,n);if(null===s)throw new g("when linking, twin is null");e.twin=s,s.twin=e}else{var e=t,s=this.getEdge(e.orig,e.dest);e.twin=s,s.twin=e}},y.prototype.conflict=function(t){return s(this.normal,t)>s(this.normal,this.verts[0])+C},y.prototype.getHorizon=function(){for(var t=0;t<3;t++)if(null!==this.edges[t].twin&&this.edges[t].twin.isHorizon())return this.edges[t];return null},y.prototype.removeConflict=function(){this.conflicts.removeAll()},x.prototype.init=function(t,i){this.points=[];for(var n=0;n<i.length;n++)this.points[n]=new a(i[n].x,i[n].y,i[n].z,null,i[n],(!1));this.points=this.points.concat(t)},x.prototype.permutate=function(){for(var t=this.points.length,i=t-1;i>0;i--){var n=Math.floor(Math.random()*i),e=this.points[n];e.index=i;var s=this.points[i];s.index=n,this.points.splice(n,1,s),this.points.splice(i,1,e)}},x.prototype.prep=function(){if(this.points.length<=3)throw new g("Less than 4 points");for(var t=0;t<this.points.length;t++)this.points[t].index=t;var i,n,r,h,l,u,c,a;i=this.points[0],n=this.points[1],r=h=null;for(var t=2;t<this.points.length;t++)if(!o(i,this.points[t])||!o(n,this.points[t])){r=this.points[t],r.index=2,this.points[2].index=t,this.points.splice(t,1,this.points[2]),this.points.splice(2,1,r);break}if(null===r)throw new g("Not enough non-planar Points (v2 is null)");a=new y(i,n,r);for(var t=3;t<this.points.length;t++)if(!e(s(a.normal,a.verts[0])-s(a.normal,this.points[t]))){h=this.points[t],h.index=3,this.points[3].index=t,this.points.splice(t,1,this.points[3]),this.points.splice(3,1,h);break}if(null===h)throw new g("Not enough non-planar Points (v3 is null)");a.orient(h),l=new y(i,r,h,n),u=new y(i,n,h,r),c=new y(n,r,h,i),this.addFacet(a),this.addFacet(l),this.addFacet(u),this.addFacet(c),a.link(l,i,r),a.link(u,i,n),a.link(c,n,r),l.link(u,i,h),l.link(c,r,h),u.link(c,h,n),this.current=4;for(var f,t=this.current;t<this.points.length;t++)f=this.points[t],a.conflict(f)&&this.addConflict(a,f),l.conflict(f)&&this.addConflict(l,f),u.conflict(f)&&this.addConflict(u,f),c.conflict(f)&&this.addConflict(c,f)},x.prototype.addConflicts=function(t,i,n){var e,s,o,r,h=t.conflicts.getVertices(),l=i.conflicts.getVertices(),u=[];for(o=r=0;o<h.length||r<l.length;)o<h.length&&r<l.length?(e=h[o],s=l[r],e.index===s.index?(u.push(e),o++,r++):e.index>s.index?(u.push(e),o++):(u.push(s),r++)):o<h.length?u.push(h[o++]):u.push(l[r++]);for(var o=u.length-1;o>=0;o--)e=u[o],n.conflict(e)&&this.addConflict(n,e)},x.prototype.addConflict=function(t,i){var n=new u(t,i);t.conflicts.add(n),i.conflicts.add(n)},x.prototype.removeConflict=function(t){t.removeConflict();var i=t.index;if(t.index=-1,i===this.facets.length-1)return void this.facets.splice(this.facets.length-1,1);if(!(i>=this.facets.length||i<0)){var n=this.facets.splice(this.facets.length-1,1);n[0].index=i,this.facets.splice(i,1,n[0])}},x.prototype.addFacet=function(t){t.index=this.facets.length,this.facets.push(t)},x.prototype.compute=function(){for(this.prep();this.current<this.points.length;){var t=this.points[this.current];if(t.conflicts.isEmpty())this.current++;else{this.created=[],this.horizon=[],this.visible=[],t.conflicts.fill(this.visible);for(var i,n=0;n<this.visible.length;n++)if(i=this.visible[n].getHorizon(),null!==i){i.findHorizon(this.horizon);break}for(var e=null,s=null,o=0;o<this.horizon.length;o++){var r=this.horizon[o],h=new y(t,r.orig,r.dest,r.twin.next.dest);h.conflicts=new c((!0)),this.addFacet(h),this.created.push(h),this.addConflicts(r.iFace,r.twin.iFace,h),h.link(r),null!==e&&h.link(e,t,r.orig),e=h,null===s&&(s=h)}if(null!==s&&null!==e&&e.link(s,t,this.horizon[0].orig),0!=this.created.length){for(var l=0;l<this.visible.length;l++)this.removeConflict(this.visible[l]);this.current++,this.created=[]}}}return this.facets},x.prototype.clear=function(){this.points=[],this.facets=[],this.created=[],this.horizon=[],this.visible=[],this.current=0},t.weightedVoronoi=P,t.d3WeightedVoronoiError=g,Object.defineProperty(t,"__esModule",{value:!0})});