@@ -4533,43 +4533,43 @@ d3 = function() {
45334533 var a = coordinates [ 0 ] , b = coordinates [ coordinates . length - 1 ] ;
45344534 return ! ( a [ 0 ] - b [ 0 ] || a [ 1 ] - b [ 1 ] ) ;
45354535 }
4536- var d3_geom_voronoiEdges , d3_geom_voronoiCells , d3_geom_voronoiBeachLine , d3_geom_voronoiBeachSectionJunkyard = [ ] , d3_geom_voronoiCircleEvents , d3_geom_voronoiCircleEventJunkyard = [ ] , d3_geom_voronoiFirstCircleEvent ;
4537- function d3_geom_voronoiBeachSection ( ) {
4536+ var d3_geom_voronoiEdges , d3_geom_voronoiCells , d3_geom_voronoiBeaches , d3_geom_voronoiBeachJunkyard = [ ] , d3_geom_voronoiFirstCircle , d3_geom_voronoiCircles , d3_geom_voronoiCircleJunkyard = [ ] ;
4537+ function d3_geom_voronoiBeach ( ) {
45384538 d3_geom_voronoiRedBlackNode . call ( this ) ;
4539- this . edge = this . site = this . circleEvent = null ;
4540- }
4541- function d3_geom_voronoiCreateBeachSection ( site ) {
4542- var beachSection = d3_geom_voronoiBeachSectionJunkyard . pop ( ) ;
4543- if ( ! beachSection ) beachSection = new d3_geom_voronoiBeachSection ( ) ;
4544- beachSection . site = site ;
4545- return beachSection ;
4546- }
4547- function d3_geom_voronoiDetachBeachSection ( beachSection ) {
4548- d3_geom_voronoiDetachCircleEvent ( beachSection ) ;
4549- d3_geom_voronoiBeachLine . remove ( beachSection ) ;
4550- d3_geom_voronoiBeachSectionJunkyard . push ( beachSection ) ;
4551- }
4552- function d3_geom_voronoiRemoveBeachSection ( beachSection ) {
4553- var circle = beachSection . circleEvent , x = circle [ 0 ] , y = circle . cy , vertex = [ x , y ] , previous = beachSection . P , next = beachSection . N , disappearingTransitions = [ beachSection ] ;
4554- d3_geom_voronoiDetachBeachSection ( beachSection ) ;
4539+ this . edge = this . site = this . circle = null ;
4540+ }
4541+ function d3_geom_voronoiCreateBeach ( site ) {
4542+ var beach = d3_geom_voronoiBeachJunkyard . pop ( ) ;
4543+ if ( ! beach ) beach = new d3_geom_voronoiBeach ( ) ;
4544+ beach . site = site ;
4545+ return beach ;
4546+ }
4547+ function d3_geom_voronoiDetachBeach ( beach ) {
4548+ d3_geom_voronoiDetachCircle ( beach ) ;
4549+ d3_geom_voronoiBeaches . remove ( beach ) ;
4550+ d3_geom_voronoiBeachJunkyard . push ( beach ) ;
4551+ }
4552+ function d3_geom_voronoiRemoveBeach ( beach ) {
4553+ var circle = beach . circle , x = circle [ 0 ] , y = circle . cy , vertex = [ x , y ] , previous = beach . P , next = beach . N , disappearingTransitions = [ beach ] ;
4554+ d3_geom_voronoiDetachBeach ( beach ) ;
45554555 var lArc = previous ;
4556- while ( lArc . circleEvent && Math . abs ( x - lArc . circleEvent [ 0 ] ) < ε && Math . abs ( y - lArc . circleEvent . cy ) < ε ) {
4556+ while ( lArc . circle && Math . abs ( x - lArc . circle [ 0 ] ) < ε && Math . abs ( y - lArc . circle . cy ) < ε ) {
45574557 previous = lArc . P ;
45584558 disappearingTransitions . unshift ( lArc ) ;
4559- d3_geom_voronoiDetachBeachSection ( lArc ) ;
4559+ d3_geom_voronoiDetachBeach ( lArc ) ;
45604560 lArc = previous ;
45614561 }
45624562 disappearingTransitions . unshift ( lArc ) ;
4563- d3_geom_voronoiDetachCircleEvent ( lArc ) ;
4563+ d3_geom_voronoiDetachCircle ( lArc ) ;
45644564 var rArc = next ;
4565- while ( rArc . circleEvent && Math . abs ( x - rArc . circleEvent [ 0 ] ) < ε && Math . abs ( y - rArc . circleEvent . cy ) < ε ) {
4565+ while ( rArc . circle && Math . abs ( x - rArc . circle [ 0 ] ) < ε && Math . abs ( y - rArc . circle . cy ) < ε ) {
45664566 next = rArc . N ;
45674567 disappearingTransitions . push ( rArc ) ;
4568- d3_geom_voronoiDetachBeachSection ( rArc ) ;
4568+ d3_geom_voronoiDetachBeach ( rArc ) ;
45694569 rArc = next ;
45704570 }
45714571 disappearingTransitions . push ( rArc ) ;
4572- d3_geom_voronoiDetachCircleEvent ( rArc ) ;
4572+ d3_geom_voronoiDetachCircle ( rArc ) ;
45734573 var nArcs = disappearingTransitions . length , iArc ;
45744574 for ( iArc = 1 ; iArc < nArcs ; ++ iArc ) {
45754575 rArc = disappearingTransitions [ iArc ] ;
@@ -4579,11 +4579,11 @@ d3 = function() {
45794579 lArc = disappearingTransitions [ 0 ] ;
45804580 rArc = disappearingTransitions [ nArcs - 1 ] ;
45814581 rArc . edge = d3_geom_voronoiCreateEdge ( lArc . site , rArc . site , undefined , vertex ) ;
4582- d3_geom_voronoiAttachCircleEvent ( lArc ) ;
4583- d3_geom_voronoiAttachCircleEvent ( rArc ) ;
4582+ d3_geom_voronoiAttachCircle ( lArc ) ;
4583+ d3_geom_voronoiAttachCircle ( rArc ) ;
45844584 }
4585- function d3_geom_voronoiAddBeachSection ( site ) {
4586- var x = site [ 0 ] , directrix = site [ 1 ] , lArc , rArc , dxl , dxr , node = d3_geom_voronoiBeachLine . _ ;
4585+ function d3_geom_voronoiAddBeach ( site ) {
4586+ var x = site [ 0 ] , directrix = site [ 1 ] , lArc , rArc , dxl , dxr , node = d3_geom_voronoiBeaches . _ ;
45874587 while ( node ) {
45884588 dxl = d3_geom_voronoiLeftBreakPoint ( node , directrix ) - x ;
45894589 if ( dxl > ε ) node = node . L ; else {
@@ -4608,30 +4608,30 @@ d3 = function() {
46084608 }
46094609 }
46104610 }
4611- var newArc = d3_geom_voronoiCreateBeachSection ( site ) ;
4612- d3_geom_voronoiBeachLine . insert ( lArc , newArc ) ;
4611+ var newArc = d3_geom_voronoiCreateBeach ( site ) ;
4612+ d3_geom_voronoiBeaches . insert ( lArc , newArc ) ;
46134613 if ( ! lArc && ! rArc ) return ;
46144614 if ( lArc === rArc ) {
4615- d3_geom_voronoiDetachCircleEvent ( lArc ) ;
4616- rArc = d3_geom_voronoiCreateBeachSection ( lArc . site ) ;
4617- d3_geom_voronoiBeachLine . insert ( newArc , rArc ) ;
4615+ d3_geom_voronoiDetachCircle ( lArc ) ;
4616+ rArc = d3_geom_voronoiCreateBeach ( lArc . site ) ;
4617+ d3_geom_voronoiBeaches . insert ( newArc , rArc ) ;
46184618 newArc . edge = rArc . edge = d3_geom_voronoiCreateEdge ( lArc . site , newArc . site ) ;
4619- d3_geom_voronoiAttachCircleEvent ( lArc ) ;
4620- d3_geom_voronoiAttachCircleEvent ( rArc ) ;
4619+ d3_geom_voronoiAttachCircle ( lArc ) ;
4620+ d3_geom_voronoiAttachCircle ( rArc ) ;
46214621 return ;
46224622 }
46234623 if ( ! rArc ) {
46244624 newArc . edge = d3_geom_voronoiCreateEdge ( lArc . site , newArc . site ) ;
46254625 return ;
46264626 }
4627- d3_geom_voronoiDetachCircleEvent ( lArc ) ;
4628- d3_geom_voronoiDetachCircleEvent ( rArc ) ;
4627+ d3_geom_voronoiDetachCircle ( lArc ) ;
4628+ d3_geom_voronoiDetachCircle ( rArc ) ;
46294629 var lSite = lArc . site , ax = lSite [ 0 ] , ay = lSite [ 1 ] , bx = site [ 0 ] - ax , by = site [ 1 ] - ay , rSite = rArc . site , cx = rSite [ 0 ] - ax , cy = rSite [ 1 ] - ay , d = 2 * ( bx * cy - by * cx ) , hb = bx * bx + by * by , hc = cx * cx + cy * cy , vertex = [ ( cy * hb - by * hc ) / d + ax , ( bx * hc - cx * hb ) / d + ay ] ;
46304630 d3_geom_voronoiSetEdgeStartpoint ( rArc . edge , lSite , rSite , vertex ) ;
46314631 newArc . edge = d3_geom_voronoiCreateEdge ( lSite , site , null , vertex ) ;
46324632 rArc . edge = d3_geom_voronoiCreateEdge ( site , rSite , null , vertex ) ;
4633- d3_geom_voronoiAttachCircleEvent ( lArc ) ;
4634- d3_geom_voronoiAttachCircleEvent ( rArc ) ;
4633+ d3_geom_voronoiAttachCircle ( lArc ) ;
4634+ d3_geom_voronoiAttachCircle ( rArc ) ;
46354635 }
46364636 function d3_geom_voronoiLeftBreakPoint ( arc , directrix ) {
46374637 var site = arc . site , rfocx = site [ 0 ] , rfocy = site [ 1 ] , pby2 = rfocy - directrix ;
@@ -4695,30 +4695,30 @@ d3 = function() {
46954695 }
46964696 }
46974697 }
4698- function d3_geom_voronoiCircleEvent ( ) {
4698+ function d3_geom_voronoiCircle ( ) {
46994699 d3_geom_voronoiRedBlackNode . call ( this ) ;
47004700 this [ 0 ] = this [ 1 ] = this . arc = this . site = this . cy = null ;
47014701 }
4702- function d3_geom_voronoiAttachCircleEvent ( arc ) {
4702+ function d3_geom_voronoiAttachCircle ( arc ) {
47034703 var lArc = arc . P , rArc = arc . N ;
47044704 if ( ! lArc || ! rArc ) return ;
47054705 var lSite = lArc . site , cSite = arc . site , rSite = rArc . site ;
47064706 if ( lSite === rSite ) return ;
47074707 var bx = cSite [ 0 ] , by = cSite [ 1 ] , ax = lSite [ 0 ] - bx , ay = lSite [ 1 ] - by , cx = rSite [ 0 ] - bx , cy = rSite [ 1 ] - by ;
47084708 var d = 2 * ( ax * cy - ay * cx ) ;
47094709 if ( d >= - ε2 ) return ;
4710- var ha = ax * ax + ay * ay , hc = cx * cx + cy * cy , x = ( cy * ha - ay * hc ) / d , y = ( ax * hc - cx * ha ) / d , ycenter = y + by ;
4711- var circleEvent = d3_geom_voronoiCircleEventJunkyard . pop ( ) ;
4712- if ( ! circleEvent ) circleEvent = new d3_geom_voronoiCircleEvent ( ) ;
4713- circleEvent . arc = arc ;
4714- circleEvent . site = cSite ;
4715- circleEvent [ 0 ] = x + bx ;
4716- circleEvent [ 1 ] = ycenter + Math . sqrt ( x * x + y * y ) ;
4717- circleEvent . cy = ycenter ;
4718- arc . circleEvent = circleEvent ;
4719- var predecessor = null , node = d3_geom_voronoiCircleEvents . _ ;
4710+ var ha = ax * ax + ay * ay , hc = cx * cx + cy * cy , x = ( cy * ha - ay * hc ) / d , y = ( ax * hc - cx * ha ) / d , cy = y + by ;
4711+ var circle = d3_geom_voronoiCircleJunkyard . pop ( ) ;
4712+ if ( ! circle ) circle = new d3_geom_voronoiCircle ( ) ;
4713+ circle . arc = arc ;
4714+ circle . site = cSite ;
4715+ circle [ 0 ] = x + bx ;
4716+ circle [ 1 ] = cy + Math . sqrt ( x * x + y * y ) ;
4717+ circle . cy = cy ;
4718+ arc . circle = circle ;
4719+ var predecessor = null , node = d3_geom_voronoiCircles . _ ;
47204720 while ( node ) {
4721- if ( circleEvent [ 1 ] < node [ 1 ] || circleEvent [ 1 ] === node [ 1 ] && circleEvent [ 0 ] <= node [ 0 ] ) {
4721+ if ( circle [ 1 ] < node [ 1 ] || circle [ 1 ] === node [ 1 ] && circle [ 0 ] <= node [ 0 ] ) {
47224722 if ( node . L ) node = node . L ; else {
47234723 predecessor = node . P ;
47244724 break ;
@@ -4730,16 +4730,16 @@ d3 = function() {
47304730 }
47314731 }
47324732 }
4733- d3_geom_voronoiCircleEvents . insert ( predecessor , circleEvent ) ;
4734- if ( ! predecessor ) d3_geom_voronoiFirstCircleEvent = circleEvent ;
4733+ d3_geom_voronoiCircles . insert ( predecessor , circle ) ;
4734+ if ( ! predecessor ) d3_geom_voronoiFirstCircle = circle ;
47354735 }
4736- function d3_geom_voronoiDetachCircleEvent ( arc ) {
4737- var circle = arc . circleEvent ;
4736+ function d3_geom_voronoiDetachCircle ( arc ) {
4737+ var circle = arc . circle ;
47384738 if ( circle ) {
4739- if ( ! circle . P ) d3_geom_voronoiFirstCircleEvent = circle . N ;
4740- d3_geom_voronoiCircleEvents . remove ( circle ) ;
4741- d3_geom_voronoiCircleEventJunkyard . push ( circle ) ;
4742- arc . circleEvent = null ;
4739+ if ( ! circle . P ) d3_geom_voronoiFirstCircle = circle . N ;
4740+ d3_geom_voronoiCircles . remove ( circle ) ;
4741+ d3_geom_voronoiCircleJunkyard . push ( circle ) ;
4742+ arc . circle = null ;
47434743 }
47444744 }
47454745 function d3_geom_voronoiClipEdges ( bbox ) {
@@ -5081,19 +5081,19 @@ d3 = function() {
50815081 var site = sites . sort ( d3_geom_voronoiVertexOrder ) . pop ( ) , x0 , y0 , circle ;
50825082 d3_geom_voronoiEdges = [ ] ;
50835083 d3_geom_voronoiCells = new Array ( sites . length ) ;
5084- d3_geom_voronoiBeachLine = new d3_geom_voronoiRedBlackTree ( ) ;
5085- d3_geom_voronoiCircleEvents = new d3_geom_voronoiRedBlackTree ( ) ;
5084+ d3_geom_voronoiBeaches = new d3_geom_voronoiRedBlackTree ( ) ;
5085+ d3_geom_voronoiCircles = new d3_geom_voronoiRedBlackTree ( ) ;
50865086 while ( true ) {
5087- circle = d3_geom_voronoiFirstCircleEvent ;
5087+ circle = d3_geom_voronoiFirstCircle ;
50885088 if ( site && ( ! circle || site [ 1 ] < circle [ 1 ] || site [ 1 ] === circle [ 1 ] && site [ 0 ] < circle [ 0 ] ) ) {
50895089 if ( site [ 0 ] !== x0 || site [ 1 ] !== y0 ) {
50905090 d3_geom_voronoiCells [ site . i ] = new d3_geom_voronoiCell ( site ) ;
5091- d3_geom_voronoiAddBeachSection ( site ) ;
5091+ d3_geom_voronoiAddBeach ( site ) ;
50925092 x0 = site [ 0 ] , y0 = site [ 1 ] ;
50935093 }
50945094 site = sites . pop ( ) ;
50955095 } else if ( circle ) {
5096- d3_geom_voronoiRemoveBeachSection ( circle . arc ) ;
5096+ d3_geom_voronoiRemoveBeach ( circle . arc ) ;
50975097 } else {
50985098 break ;
50995099 }
@@ -5104,7 +5104,7 @@ d3 = function() {
51045104 cells : d3_geom_voronoiCells ,
51055105 edges : d3_geom_voronoiEdges
51065106 } ;
5107- d3_geom_voronoiBeachLine = d3_geom_voronoiCircleEvents = d3_geom_voronoiEdges = d3_geom_voronoiCells = null ;
5107+ d3_geom_voronoiBeaches = d3_geom_voronoiCircles = d3_geom_voronoiEdges = d3_geom_voronoiCells = null ;
51085108 return diagram ;
51095109 }
51105110 d3 . geom . voronoi = function ( points ) {
0 commit comments