(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 4.0, MathReader 4.0, or any compatible application. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 26539, 959]*) (*NotebookOutlinePosition[ 27430, 989]*) (* CellTagsIndexPosition[ 27386, 985]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["All k-th order Voronoi diagrams, simultanuously.", "Subtitle", PageWidth->PaperWidth], Cell[CellGroupData[{ Cell["Code", "Section"], Cell["\<\ < *) \t\t{a,d,e}, \t\ta = ca[xyz]; \t\tIf[ a==0, \t\t\tPrint[\"Dividing by zero\"]; \t\t]; \t\td = cd[xyz]; \t\te = ce[xyz]; \t\t{-d/(2a),-e/(2a)} \t] distance[l_List] := Module[ \t\t(* square of euclidean distance *) \t\t{}, \t(l[[1,1]]-l[[2,1]])^2 +(l[[1,2]]-l[[2,2]])^2 \t\t\t] allkvoronoi[points_List] := Module[ \t\t(* gets all voronoi circles and the points they contain *) \t\t{l, rr, lc, circlelist, thiscircle, i, center, radius, otherpoints, k,h, \ j}, \t\tl = Length[points]; \t\trr = Range[l]; \t\t(* lc = #of different circles *) \t\tlc = Binomial[l,3]; \t\tcirclelist = {}; \t\tthiscircle = {1,2,3}; \t\t(* Use the undocumented function `NextKSubset' *) \t\tFor[ i=1 , i <= lc, \t\t\tcenter = circlecenter[ points[[thiscircle]] ]; \t\t\tradius = distance[{points[[thiscircle]][[1]], center}]; \t\t\totherpoints = Complement[ rr, thiscircle]; \t\t\tk = {}; \t\t\tFor[ j=1, j <= (l-3), \t\t\t\th = otherpoints[[j]]; \t\t\t\tIf[ distance[{points[[h]],center}] < radius, \t\t\t\t\t\tk=Append[k,h]; \t\t\t\t\t]; \t\t\t\tj++; \t\t\t]; \t\t\tcirclelist = Append[circlelist, {i, thiscircle, N[center], k}]; \t\t\tthiscircle = NextKSubset[rr,thiscircle]; \t\t\ti++; \t]; \tcirclelist ]\t aroundvpoint[circle_,k_] := Module[ \t\t(* gets the edges and faces incident with a < k>-th order voronoi vertex () *) \t\t{nr,order, points, edges, nrinpoints, inpoints, regions}, \t\tnr = circle[[1]]; \t\torder = {1,3,2}; \t\torder2={3,1,2}; \t\tpoints = circle[[2]]; \t\tedges= KSubsets[ points,2]; \t\tinpoints = circle[[4]]; \t\tnrinpoints = Length[circle[[4]]]; \t\tIf[ nrinpoints== k-2, \t\t\tregions = Table[Sort[Join[edges[[order2[[i]]]], inpoints]],{i,3}]; \t\t]; \t\tIf[ nrinpoints == k-1, \t\t\tregions = Table[Sort[Append[inpoints, points[[order[[i]] ]] ] ],{i,3}]; \t\t]; \t\t{nr, edges, regions} \t] edgesandregions[struc_, k_] := Module[ \t\t(* Get all circles that contain k-2or k-1 points *) \t\t{nr, kstruc,lci, i, ci}, \t\tnr = Length[struc]; \t\tkstruc = {}; \t For[ i=1, i <= nr, \t\t\tci = struc[[i]]; \t\t\tlci = Length[ci[[4]]]; \t\t\tIf[ lci== k-2 || lci == k-1, \t\t\t\tkstruc = Append[kstruc, aroundvpoint[ci, k]]; \t\t\t]; \t\t\ti++; \t]; \tkstruc ] buildedges[ek_] := Module[ \t\t(* build all edges from the incident faces and edges info in *) \t\t{cek, nrv, edges, i, edge, faces, ii, jj, al}, \t\tcek = ek; \t\tnrv = Length[ cek ]; \t\tedges = {}; \t\tFor[ i=1, i < nrv, \t\t\tFor[ j=1, j<= Length[ cek[[i,2]] ], \t\t\t\tedge = cek[[i,2]][[j]]; \t\t\t\tfaces = cek[[i,3]]; \t\t\t\tFor[ ii=i+1, ii <= nrv, \t\t\t\t\tal = Length[ cek[[ii,2]] ]; \t\t\t\t\tFor[ jj=1, jj <= al, \t\t\t\t\t\tIf[ cek[[ii,2]][[ jj]] == edge, \t\t\t\t\t\t\tIf[ Length[Intersection[ faces, cek[[ii,3]] ] ] == 2, \t\t\t\t\t\t\t\tedges = Append[ edges, {cek[[i,1]], cek[[ii,1]] }]; \t\t\t\t\t\t\t\tcek = Delete[ cek, {ii,2,jj} ]; \t\t\t\t\t\t\t\tjj = 4; \t\t\t\t\t\t\t ii = nrv+1; \t\t\t\t\t\t\t]; \t\t\t\t\t\t]; \t\t\t\t\t\tjj++; \t\t\t\t\t]; \t\t\t\t\tii++; \t\t\t\t]; \t\t\t j++; \t\t]; \ti++; ]; edges ]\t\t \t\t showallkvoronoi[ points_] := Module[ \t\t(* Shows all n-1 Voronoi diagrams, defined by $n$ points, simultanuously \ *) \t\t{n, akv, alllines, k, edreg, edgerel, lines, i, b, e}, \t\tn = Length[ points ]; \t\takv = allkvoronoi[ points ]; \t\talllines = {Thickness[.01]}; \t\tFor[k=1, k All, AspectRatio -> Automatic , Axes -> False] \t\t]\t\t showallkvoronoi[ points_, range_] := Module[ \t\t(* Shows all n-1 Voronoi diagrams, defined by $n$ points, simultanuously \ *) \t\t{n, akv, alllines, k, edreg, edgerel, lines, i, b, e}, \t\tn = Length[ points ]; \t\takv = allkvoronoi[ points ]; \t\talllines = {Thickness[.004]}; \t\tFor[k=1, k range, AspectRatio -> Automatic , Axes -> True] \t\t]\t\t showkvoronoi[points_, k_Integer] := Module[ \t\t(* Shows the k-th order Voronoi diagram *) \t\t{n, akv, alllines, edreg, edgerel, i, lines}, \t\tn = Length[ points ]; \t akv = allkvoronoi[ points ]; \t alllines = {Thickness[.002]}; \t\tedreg = edgesandregions[ akv, k]; \t\tedgerel = buildedges[edreg]; \t\tlines = {}; \t\tFor[ i = 1, i <= Length[ edgerel], \t\t\t\tb = edgerel[[i,1]]; \t\t\t\te = edgerel[[i,2]]; \t\t\t\tlines = Append[ lines,Line[ {akv[[b,3]], akv[[e,3]]}]]; \t\t\t i++; \t\t]; \t\talllines = Join[{Thickness[.01], Hue[N[k/n]]}, lines]; \t\tShow[Graphics[alllines], PlotRange -> All,AspectRatio -> Automatic] \t]\t showsomekvoronoi[ points_,l_List] := Module[ \t\t(* Shows the combined Voronoi diagrams for the orders present in *) \t\t{n, akv, alllines, k, edreg, edgerel, lines, i, b, e,j}, \t\tn = Length[ points ]; \t\takv = allkvoronoi[ points ]; \t\talllines = {Thickness[.01]}; \t\tFor[j=1, j <=Length[l], \t\t\tk = l[[j]]; \t\t\tedreg = edgesandregions[ akv, k]; \t\t\tedgerel = buildedges[edreg]; \t\t\tlines = {}; \t\t\tFor[ i = 1, i <= Length[ edgerel], \t\t\t\tb = edgerel[[i,1]]; \t\t\t\te = edgerel[[i,2]]; \t\t\t\tlines = Append[ lines,Line[ {akv[[b,3]], akv[[e,3]]}]]; \t\t\t i++; \t\t\t]; \t\t\talllines = Append[alllines, Join[ {Hue[N[k/n]]}, lines]]; \t\t\tj++; \t\t]; \t\tShow[Graphics[alllines],PlotRange -> All, AspectRatio -> Automatic , Axes -> True] \t\t]\t\t showsomekvoronoi[ points_,l_List, range_] := Module[ \t\t(* Shows the combined Voronoi diagrams for the orders present in *) \t\t{n, akv, alllines, k, edreg, edgerel, lines, i, b, e,j}, \t\tn = Length[ points ]; \t\takv = allkvoronoi[ points ]; \t\talllines = {Thickness[.01]}; \t\tFor[j=1, j <=Length[l], \t\t\tk = l[[j]]; \t\t\tedreg = edgesandregions[ akv, k]; \t\t\tedgerel = buildedges[edreg]; \t\t\tlines = {}; \t\t\tFor[ i = 1, i <= Length[ edgerel], \t\t\t\tb = edgerel[[i,1]]; \t\t\t\te = edgerel[[i,2]]; \t\t\t\tlines = Append[ lines,Line[ {akv[[b,3]], akv[[e,3]]}]]; \t\t\t i++; \t\t\t]; \t\t\talllines = Append[alllines, Join[ {Hue[N[k/n]]}, lines]]; \t\t\tj++; \t\t]; \t\tShow[Graphics[alllines],PlotRange -> range, AspectRatio -> Automatic , Axes -> True] \t\t]\t\t voronoiflist[points_] := Module[ \t\t(* Returns all Voronoi faces defined by *) \t\t{n, akv, allfaces, i, faces, ear, j}, \t\tn = Length[points]; \t\takv = allkvoronoi[points]; \t\tallfaces = {{Range[n]}}; \t\tFor[ i=n-1, i >= 1, \t\t\tfaces = {}; \t\t\tear = edgesandregions[akv,i]; \t\t\tFor[j=1, j <= Length[ear], \t\t\t\tfaces = Join[faces, ear[[j,3]]]; \t\t\t\tj++; \t\t\t]; \t\t\tallfaces = Append[allfaces, Union[faces]]; \t\t\ti--; \t\t]; \t\tAppend[allfaces,{{}}] \t\t] randomnvor[n_Integer] := Module[ \t\t(* computes the euler chararacteristic for a set of random points *) \t\t{r, mp, flist, fvector, avector, euler}, \t\tr := Random[Integer,{0,1000}]; \t\tmp = Table[{r,r},{i,n}]; \t\tPrint[\"points = \",mp]; \t\tflist = voronoiflist[mp]; \t\tfvector=FVector[flist]; \t\tPrint[\"fvector = \", fvector]; \t\tavector=Table[(-1)^(i),{i,Length[fvector]}]; \t euler = avector.fvector; \t\tPrint[\"\[CurlyKappa] = \", euler]; \t\teuler \t\t] cvector[points_List] := Module[ \t\t(* Returns the number of circles of order $i$ for i=0,...,n-3 *) \t\t{n, nr, cvec, akv, i}, \t\tn = Length[points]; \t\tnr = Binomial[n,3]; \t\tcvec = Table[0, {i, n-2}]; \t akv = allkvoronoi[points]; \t\tFor[i=1, i <= nr, \t\t\tcvec[[Length[ akv[[i,4]] ] + 1]]++; \t\t\ti++; \t\t]; \t\tcvec ] vvector[points_List] := Module[ \t\t(* Returns the number of vertices of the $k$-th order VD for k=1,...,n-1 \ *) \t\t{cvec,l,i}, \t\tcvec = Append[Prepend[ cvector[points],0],0]; \t\tl = Length[cvec]; \t\tTable[cvec[[i]] + cvec[[i+1]], {i,l-1}] ] finfvector[points_] := Module[ \t\t{akv, finfvec, k, edreg, occur, vertices, lv, valencies, nrunbound, j}, \t\takv = allkvoronoi[ points ]; \t\tn= Length[points]; \t\tfinfvec = {}; \t\tFor[k=1, k and the Voronoi circles of order *) \t\t{n,akv,circles,i,center,radius}, \t\tn=Length[points]; \t\tIf[ k>n-3, Return[Print[\"k is too big...\"]] ]; \t\takv = allkvoronoi[points]; \t\tcircles = { Hue[N[k/n] ]}; \t\tFor[ i=1, i <= Length[akv], \t\t\tIf[Length[ akv[[i,4]] ]==k, \t\t\t\t center = akv[[i,3]]; \t\t\t\t radius = distance[ {points[[ akv[[i,2,1]] ]], center }] \t\t\t\t\t\t// Sqrt//N; \t\t\t\t circles = Append[circles,Circle[center,radius]]; \t\t\t]; \t\t\ti++; \t\t]; \t\tl1 = Table[Text[i,points[[i]] ],{i,n}]; \t\t{Show[Graphics[{circles,l1}], \t AspectRatio -> Automatic, \t\t\tAxes -> False\t], Length[circles]-1} ] <<$HOME/cas/matica/kvoronoi/ihull.m bisector[lijst_] := Module[ \t\t\t{p1,a,b,p2,c,d}, \t\t \t\t p1 = lijst[[1]]; \t\t a = p1[[1]]; b = p1[[2]]; \t\t p2 = lijst[[2]]; \t\t c = p2[[1]]; d = p2[[2]]; \t\t If[d==b,1/2 (a +c), \t\t (a-c)/(d-b) x + (1/2) ( d+b +(c c-a a)/(d-b))] \t\t\t] bisector[p1_, p2_] := Module[ \t\t\t{a,b,c,d}, \t\t \t\t a = p1[[1]]; b = p1[[2]]; \t\t c = p2[[1]]; d = p2[[2]]; \t\t If[d==b,1/2 (a +c), \t\t (a-c)/(d-b) x + (1/2) ( d+b +(c c-a a)/(d-b))] \t\t\t] bisectorarr[points_] := Module[ \t\t{n,k,bis,x}, \t\tn = Length[points]; \t\tk = KSubsets[Range[n],2]; \t\tbis = Table[bisector[ points[[k[[i,1]] ]],points[[k[[i,2]] ]] ], \t\t\t{i,Length[k]}]//N; \t\tbis \t\t] pairtoposition[pair_,n_] := Module[ \t\t(* computes the position of an ordered pair in the enumeration of combinations of length two of [n] *) \t\t{p1,k}, \t\tp1=pair[[1]]; \t\tSum[n-k,{k,1,p1-1}]+ pair[[2]]-p1 \t\t] oneslope[p1_,p2_] := Module[ \t\t\t{a,b,c,d}, \t\t a = p1[[1]]; b = p1[[2]]; \t\t c = p2[[1]]; d = p2[[2]]; \t\t If[d==b,1/2 (a +c)//N, (a-c)/(d-b) //N] \t\t\t] allslopes[points_] := Module[ \t\t{n,k,i}, \t\tn = Length[points]; \t\tk = KSubsets[Range[n],2]; \t Table[oneslope[ points[[ k[[i,1]] ]],points[[ k[[i,2]] ]] ], \t\t\t{i,Length[k]} ] \t\t] buildedgesinf[ek_] := Module[ \t\t(* build all edges from the incident faces and edges info in *) \t\t{cek, nrv, edges, i,j, edge, faces, ii, jj, al}, \t\tcek = ek; \t\tnrv = Length[ cek ]; \t\tedges = {}; \t\tinfedges={}; \t\tFor[ i=1, i < nrv, \t\t\tFor[ j=1, j<= Length[ cek[[i,2]] ], \t\t\t\tedge = cek[[i,2]][[j]]; \t\t\t\tfaces = cek[[i,3]]; \t\t\t\tFor[ ii=i+1, ii <= nrv, \t\t\t\t\tal = Length[ cek[[ii,2]] ]; \t\t\t\t\tFor[ jj=1, jj <= al, \t\t\t\t\t\tIf[ cek[[ii,2]][[ jj]] == edge, \t\t\t\t\t\t\tIf[ Length[Intersection[ faces, cek[[ii,3]] ] ] == 2, \t\t\t\t\t\t\t\tedges = Append[ edges, {cek[[i,1]], cek[[ii,1]] }]; \t\t\t\t\t\t\t\tcek = Delete[ cek, {ii,2,jj} ]; \t\t\t\t\t\t\t\tjj = 5; \t\t\t\t\t\t\t ii = nrv+1; \t\t\t\t\t\t\t]; \t\t\t\t\t\t]; \t\t\t\t\t\tjj++; \t\t\t\t\t]; \t\t\t\t\tii++; \t\t\t\t]; \t\t\t\tIf[ jj < 5, infedges=Append[infedges,{i,edge}]]; \t\t\t j++; \t\t]; \ti++; ]; For[k=1, k <= Length[cek[[nrv,2]]], \t\t\tinfedges = Append[infedges, {i,cek[[nrv,2,k]]} ]; \t\t\tk++; ]; {edges,infedges} ]\t\t sign[p_,q_,r_] := Module[ \t\t{}, Det[{{1,p[[1]],p[[2]]}, \t\t\t\t\t{1,q[[1]],q[[2]]}, \t\t\t\t\t{1,r[[1]],r[[2]]}}]//Sign \t\t] showkvoronoiinf[points_, k_Integer] := Module[ \t\t{lines,n, akv,edreg, edgeinfo,edgerel,i,b, e,infinfo, infedge,thiscircle, slopes, slope, centre,radius,ss,s1,p1label, p2label, p3label, p1, p2, p3,alllines, tpoints, cyoung, testsign}, If[ k < 1, Return[{}]]; \t\tlines = {}; \t\tn = Length[ points ]; \t\tIf[ k >= n, Return[{}]]; \t akv = allkvoronoi[ points ]; \t\tedreg = edgesandregions[ akv, k]; \t\tedgeinfo = buildedgesinf[edreg]; \t\tedgerel = edgeinfo[[1]]; \t\t(* Add the edges *) \t\tFor[ i = 1, i <= Length[ edgerel], \t\t\t\tb = edgerel[[i,1]]; \t\t\t\te = edgerel[[i,2]]; \t\t\t\tlines = Append[ lines,Line[ {akv[[b,3]], akv[[e,3]]}]]; \t\t\t i++; \t\t]; \t\t(* Now we add the halflines *) \t slopes = allslopes[points]; \t\tinfinfo = edgeinfo[[2]]; \t\tFor[i=1, i <= Length[infinfo], \t\t\tinfedge = infinfo[[i]]; \t\t\tthiscircle=edreg[[infedge[[1]],1]] ; \t\t\t(* determine whether is young or old *) \t \thcircle = Length[ akv[[thiscircle,4]] ]; \t\t\tIf[ hcircle+2==k, cyoung = -1, cyoung = 1]; \t\t\tslope= slopes[[pairtoposition[infedge[[2]],n ] ]]; \t\t\tcentre= akv[[ edreg[[infedge[[1]],1]],3]]; \t\t\tradius = N[Sqrt[ distance[ {centre, points[[infedge[[2,1]] ]]} ] ] ]; \t\t\tss = (2.radius)/(Sqrt[1+slope^2]){1,slope}; \t\t\ts1 = ss+centre; \t\t\tp1label=infedge[[2,1]]; \t\t\tp2label=infedge[[2,2]]; \t\t\tp3label= Complement[akv[[thiscircle,2]],{p1label,p2label}][[1]]; \t\t\tp1 = points[[p1label]]; \t\t\tp2 = points[[p2label]]; \t\t\tp3= points[[p3label]]; \t\t\ttestsign = sign[p1,p2, s1] sign[ p1, p2, p3 ]; \t\t\tIf[ cyoung== testsign, \t\t\t\t\t\t\t\t\ts1 = -ss + centre; \t\t\t]; \t\t\tlines = Append[lines,Line[{centre,s1}]]; \t\t\ti++; \t\t]; \t\talllines = Join[{Thickness[.005], Hue[N[k/n]]}, lines]; \t\ttpoints = Table[Text[i,points[[i]] ],{i,n}]; Show[Graphics[{alllines,tpoints}], PlotRange -> All, AspectRatio -> Automatic] \t]\t showkvoronoiinf[points_, k_Integer,akv_ ]:= Module[ \t\t{lines,n, akv,edreg, edgeinfo,edgerel,i,b, e,infinfo, infedge,thiscircle, slopes, slope, centre,radius,ss,s1,p1label, p2label, p3label, p1, p2, p3,alllines, tpoints, cyoung, testsign}, \t\tlines = {}; \t\tn = Length[ points ]; \t\tIf[ k >= n, Return[{}]]; \t\tedreg = edgesandregions[ akv, k]; \t\tedgeinfo = buildedgesinf[edreg]; \t\tedgerel = edgeinfo[[1]]; \t\t(* Add the edges *) \t\tFor[ i = 1, i <= Length[ edgerel], \t\t\t\tb = edgerel[[i,1]]; \t\t\t\te = edgerel[[i,2]]; \t\t\t\tlines = Append[ lines,Line[ {akv[[b,3]], akv[[e,3]]}]]; \t\t\t i++; \t\t]; \t\t(* Now we add the halflines *) \t slopes = allslopes[points]; \t\tinfinfo = edgeinfo[[2]]; \t\tFor[i=1, i <= Length[infinfo], \t\t\tinfedge = infinfo[[i]]; \t\t\tthiscircle=edreg[[infedge[[1]],1]] ; \t\t\t(* determine whether is young or old *) \t \thcircle = Length[ akv[[thiscircle,4]] ]; \t\t\tIf[ hcircle+2==k, cyoung = -1, cyoung = 1]; \t\t\tslope= slopes[[pairtoposition[infedge[[2]],n ] ]]; \t\t\tcentre= akv[[ edreg[[infedge[[1]],1]],3]]; \t\t\tradius = N[Sqrt[ distance[ {centre, points[[infedge[[2,1]] ]]} ] ] ]; \t\t\tss = (2.radius)/(Sqrt[1+slope^2]){1,slope}; \t\t\ts1 = ss+centre; \t\t\tp1label=infedge[[2,1]]; \t\t\tp2label=infedge[[2,2]]; \t\t\tp3label= Complement[akv[[thiscircle,2]],{p1label,p2label}][[1]]; \t\t\tp1 = points[[p1label]]; \t\t\tp2 = points[[p2label]]; \t\t\tp3= points[[p3label]]; \t\t\ttestsign = sign[p1,p2, s1] sign[ p1, p2, p3 ]; \t\t\tIf[ cyoung== testsign, \t\t\t\t\t\t\t\t\ts1 = -ss + centre; \t\t\t]; \t\t\tlines = Append[lines,Line[{centre,s1}]]; \t\t\ti++; \t\t]; \t\talllines = Join[{Thickness[.005], Hue[N[k/n]]}, lines]; \t\ttpoints = Table[Text[i,points[[i]] ],{i,n}]; Show[Graphics[{alllines,tpoints}], PlotRange -> All, AspectRatio -> Automatic] \t]\t \ \>", "Input", PageWidth->Infinity, InitializationCell->True, ShowSpecialCharacters->False, FormatType->InputForm] }, Closed]], Cell[CellGroupData[{ Cell["Demo", "Section"], Cell[CellGroupData[{ Cell["Start with $n$ points in the plane.", "Subsection", PageWidth->PaperWidth], Cell[BoxData[ \(\(points\ = {{45, 86}, {76, 40}, {40, 42}, {1, 9}, {71, 54}}; \)\)], "Input", PageWidth->PaperWidth] }, Closed]], Cell[CellGroupData[{ Cell[TextData[{ "Compute all ", Cell[BoxData[ FormBox[ RowBox[{"(", "\[NegativeThinSpace]", GridBox[{ {"n"}, {"3"} }], "\[NegativeThinSpace]", ")"}], TraditionalForm]]], " circles defined by the points and compute for every circle the points \ they contain.\n\nformat: nr - defining points - centre - points contained " }], "Subsection", PageWidth->PaperWidth], Cell[BoxData[ \(akv\ = \ allkvoronoi[points]\)], "Input", PageWidth->PaperWidth] }, Closed]], Cell[CellGroupData[{ Cell["\<\ Now suppose we want to create the k-th Voronoi diagram. The \ vertices of the k-th VD are exactly those circles that contain (k-2) or (k-1) \ points. For every vertex that occurs in the k-th Voronoi diagram we list the \ incident edges and faces. format: nr - incident edges - incident faces\ \>", "Subsection", PageWidth->PaperWidth], Cell[BoxData[ \(e1\ = \ edgesandregions[akv, \ 1]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(e2\ = \ edgesandregions[akv, 2]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(e3\ = \ edgesandregions[akv, 3]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(e4\ = \ edgesandregions[akv, 4]\)], "Input", PageWidth->PaperWidth] }, Closed]], Cell[CellGroupData[{ Cell["\<\ Using the edges and regions incident with a Voronoi vertex at level \ $k$ we can compute the list of bounded edges in the k-th Voronoi diagram by \ looking for vertices that have common edges and 2 common Voronoi regions with \ that edge.\ \>", "Subsection", PageWidth->PaperWidth], Cell[BoxData[ \(buildedges[e1]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(buildedges[e2]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(buildedges[e3]\)], "Input", PageWidth->PaperWidth] }, Closed]], Cell[CellGroupData[{ Cell["\<\ When we know all edge relations, we can build Voronoi diagrams for \ every order at the same time or apart\ \>", "Subsection", PageWidth->PaperWidth], Cell[BoxData[ \(\(showallkvoronoi[points]; \)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(showkvoronoi[points, 1]; \)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(showkvoronoi[points, 2]; \)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(showkvoronoi[points, 3]; \)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(showkvoronoi[points, 4]; \)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(showsomekvoronoi[points, \ {2, 3}]; \)\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["\<\ We can also compute a list of all faces present in all diagrams, \ look at the f-vector, check the Euler-Poincare formula and draw the \ poset.\ \>", "Subsection"], Cell[BoxData[ \(flist\ = \ voronoiflist[points]\)], "Input"], Cell[BoxData[ \(fvector\ = \ FVector[flist]\)], "Input"], Cell[BoxData[ \(avector = \ Table[\((\(-1\))\)^i, {i, Length[fvector]}]\)], "Input"], Cell[BoxData[ \(TrueQ[avector.fvector == 0]\)], "Input"], Cell[BoxData[ \(\(Show[FaceLatticeDiagram[flist]]; \)\)], "Input"], Cell[BoxData[ \(flinks\ = \ FaceLatticeLinks[flist]\)], "Input"], Cell[BoxData[ \(Length[flinks]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Another nice set of points ", "Subsection", PageWidth->PaperWidth], Cell[BoxData[ \(\(morepoints = {{45, 64}, {31, 6}, {69, 68}, {92, 39}, {46, 1}}; \)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(s1\ = showallkvoronoi[morepoints]; \)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(showkvoronoi[morepoints, 1]; \)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(showkvoronoi[morepoints, 2]; \)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(showkvoronoi[morepoints, 3]; \)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(showkvoronoi[morepoints, 4]; \)\)], "Input", PageWidth->PaperWidth] }, Closed]], Cell[CellGroupData[{ Cell["Generate random point sets", "Subsection"], Cell[BoxData[{ \(r\ := \ Random[Integer, {0, 100}]\), \(mp\ = \ Table[\ {r, r}, {i, 5}]\)}], "Input"], Cell[BoxData[ \(\(showallkvoronoi[mp]; \)\)], "Input"], Cell[BoxData[{ \(r\ := \ Random[Integer, {0, 100}]\), \(mp\ = \ Table[\ {r, r}, {i, 5}]\)}], "Input"], Cell[BoxData[ \(\(showallkvoronoi[mp]; \)\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell[TextData[StyleBox["Adding the halflines"]], "Subsection"], Cell[BoxData[ \(\(s1 = showkvoronoiinf[points, 1]; \)\)], "Input"], Cell[BoxData[ \(\(s2 = showkvoronoiinf[points, 2]; \)\)], "Input"], Cell[BoxData[ \(\(s3 = showkvoronoiinf[points, 3]; \)\)], "Input"], Cell[BoxData[ \(\(s4 = showkvoronoiinf[points, 4]; \)\)], "Input"], Cell[BoxData[ \(\(Show[s1, s2, s3, s4, \ PlotRange\ -> \ {{\(-50\), 150}, {\(-50\), 150}}]; \)\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell[TextData[StyleBox["Adding Voronoi circles"]], "Subsection"], Cell[BoxData[ \(\(c0\ = \ showsomecircles[points, 0]; \)\)], "Input"], Cell[BoxData[ \(\(Show[s1, c0[\([1]\)]]; \)\)], "Input"], Cell[BoxData[ \(\(c1 = \ showsomecircles[points, 1]; \)\)], "Input"], Cell[BoxData[ \(\(Show[s2, c0[\([1]\)], c1[\([1]\)]]; \)\)], "Input"], Cell[BoxData[ \(\(c2 = \ showsomecircles[points, 2]; \)\)], "Input"], Cell[BoxData[ \(\(Show[s3, c1[\([1]\)], c2[\([1]\)]]; \)\)], "Input"], Cell[BoxData[ \(\(Show[s4, c2[\([1]\)]]; \)\)], "Input"] }, Closed]] }, Closed]] }, Open ]] }, FrontEndVersion->"4.0 for X", ScreenRectangle->{{0, 1280}, {0, 1024}}, AutoGeneratedPackage->Automatic, InitializationCellEvaluation->True, InitializationCellWarning->False, WindowSize->{599, 790}, WindowMargins->{{220, Automatic}, {Automatic, 95}}, PrintingPageRange->{Automatic, Automatic}, PrintingOptions->{"PaperSize"->{597.562, 842.375}, "PaperOrientation"->"Portrait", "Magnification"->1} ] (*********************************************************************** Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. ***********************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1739, 51, 93, 1, 93, "Subtitle"], Cell[CellGroupData[{ Cell[1857, 56, 23, 0, 63, "Section"], Cell[1883, 58, 18763, 650, 9627, "Input", InitializationCell->True] }, Closed]], Cell[CellGroupData[{ Cell[20683, 713, 23, 0, 43, "Section"], Cell[CellGroupData[{ Cell[20731, 717, 82, 1, 45, "Subsection"], Cell[20816, 720, 126, 3, 27, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[20979, 728, 426, 11, 96, "Subsection"], Cell[21408, 741, 87, 2, 27, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[21532, 748, 348, 8, 114, "Subsection"], Cell[21883, 758, 92, 2, 27, "Input"], Cell[21978, 762, 90, 2, 27, "Input"], Cell[22071, 766, 90, 2, 27, "Input"], Cell[22164, 770, 90, 2, 27, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[22291, 777, 293, 6, 80, "Subsection"], Cell[22587, 785, 72, 2, 27, "Input"], Cell[22662, 789, 72, 2, 27, "Input"], Cell[22737, 793, 72, 2, 27, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[22846, 800, 161, 4, 46, "Subsection"], Cell[23010, 806, 87, 2, 27, "Input"], Cell[23100, 810, 87, 2, 27, "Input"], Cell[23190, 814, 87, 2, 27, "Input"], Cell[23280, 818, 87, 2, 27, "Input"], Cell[23370, 822, 87, 2, 27, "Input"], Cell[23460, 826, 73, 1, 27, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[23570, 832, 173, 4, 46, "Subsection"], Cell[23746, 838, 65, 1, 27, "Input"], Cell[23814, 841, 61, 1, 27, "Input"], Cell[23878, 844, 88, 1, 27, "Input"], Cell[23969, 847, 60, 1, 27, "Input"], Cell[24032, 850, 70, 1, 27, "Input"], Cell[24105, 853, 69, 1, 27, "Input"], Cell[24177, 856, 47, 1, 27, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[24261, 862, 74, 1, 29, "Subsection"], Cell[24338, 865, 128, 3, 27, "Input"], Cell[24469, 870, 98, 2, 27, "Input"], Cell[24570, 874, 91, 2, 27, "Input"], Cell[24664, 878, 91, 2, 27, "Input"], Cell[24758, 882, 91, 2, 27, "Input"], Cell[24852, 886, 91, 2, 27, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[24980, 893, 48, 0, 29, "Subsection"], Cell[25031, 895, 112, 2, 43, "Input"], Cell[25146, 899, 58, 1, 27, "Input"], Cell[25207, 902, 112, 2, 43, "Input"], Cell[25322, 906, 58, 1, 27, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[25417, 912, 62, 0, 29, "Subsection"], Cell[25482, 914, 70, 1, 27, "Input"], Cell[25555, 917, 70, 1, 27, "Input"], Cell[25628, 920, 70, 1, 27, "Input"], Cell[25701, 923, 70, 1, 27, "Input"], Cell[25774, 926, 119, 2, 27, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[25930, 933, 64, 0, 29, "Subsection"], Cell[25997, 935, 74, 1, 27, "Input"], Cell[26074, 938, 60, 1, 27, "Input"], Cell[26137, 941, 72, 1, 27, "Input"], Cell[26212, 944, 73, 1, 27, "Input"], Cell[26288, 947, 72, 1, 27, "Input"], Cell[26363, 950, 73, 1, 27, "Input"], Cell[26439, 953, 60, 1, 27, "Input"] }, Closed]] }, Closed]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)