(*********************************************************************** 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[ 16445, 448]*) (*NotebookOutlinePosition[ 17473, 480]*) (* CellTagsIndexPosition[ 17429, 476]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["The programs.", "Subsection", PageWidth->WindowWidth], Cell[BoxData[ \(<< mima.m\)], "Input", PageWidth->WindowWidth, InitializationCell->True], Cell[BoxData[ \(circlecenter[xyz_List] := Module[\[IndentingNewLine] (*\ computes\ the\ centre\ of\ the\ circle, defined\ by\ the\ points < xyz > \ *) \[IndentingNewLine]{a, d, e}, \[IndentingNewLine]a = ca[xyz]; \[IndentingNewLine]If[ a \[Equal] 0, \(Print["\"];\)]; \[IndentingNewLine]d = cd[xyz]; \[IndentingNewLine]e = ce[xyz]; \[IndentingNewLine]{Limit[\(-d\)/\((2 a)\), \ t\ \[Rule] \ 0], Limit[\(-e\)/\((2 a)\), \ t\ \[Rule] \ 0]}\[IndentingNewLine]]\)], "Input", PageWidth->WindowWidth, InitializationCell->True], Cell[BoxData[ \(unbedges[\ alledges_]\ := \ Module[\[IndentingNewLine]{nrpos, \ i, \ uedges}, \[IndentingNewLine]uedges = {}; \[IndentingNewLine]nrpos\ \ = \ Table[Length[\ Position[alledges, alledges[\([i]\)], 1]], {i, 1, \ Length[alledges]}]; \[IndentingNewLine]For[i = 1, \ i\ \[LessEqual] \ Length[\ alledges], \[IndentingNewLine]If[\ nrpos[\([i]\)]\ \[Equal] \ 1, \[IndentingNewLine]\(uedges\ = \ Append[\ uedges, \ alledges[\([i]\)]];\)\[IndentingNewLine]]; \ \[IndentingNewLine]\(i++\)\[IndentingNewLine]]; \[IndentingNewLine]uedges\ \[IndentingNewLine]]\)], "Input", PageWidth->WindowWidth, InitializationCell->True], Cell[BoxData[ \(ctoe[\ c_]\ := \[IndentingNewLine]{Sort[{c[\([1]\)], c[\([2]\)]}], \[IndentingNewLine]Sort[{c[\([2]\)], c[\([3]\)]}], \[IndentingNewLine]Sort[{c[\([3]\)], c[\([1]\)]}]}\)], "Input", PageWidth->WindowWidth, InitializationCell->True], Cell[BoxData[ \(checkorient[pp_]\ := \ Module[\[IndentingNewLine]{ld, \ s}, \[IndentingNewLine]ld\ = \ linedet[pp]; \[IndentingNewLine]s\ = \ psign[ld]; \[IndentingNewLine]If[\ s\ \[Equal] \ 0, Return[False]\ ]; \[IndentingNewLine]If[s\ \[Equal] \ 1, \ Return[\ \(-1\)]\ ]; \[IndentingNewLine]1\[IndentingNewLine]]\)], \ "Input", PageWidth->WindowWidth, InitializationCell->True], Cell[BoxData[ \(emptycircles[polpp_List] := Module[\[IndentingNewLine] (*\ gets\ all\ voronoi\ circles\ for\ a\ list\ of\ polynomial\ sites\ \ *) \[IndentingNewLine]{l, rr, lc, circlelist, thiscircle, i, cp, \ changeor, \ ocircle, \ otherpoints, j, \ empty, \ h, \ tocheck}, \[IndentingNewLine]l = Length[polpp]; \[IndentingNewLine]rr = Range[l]; \[IndentingNewLine]\[IndentingNewLine] (*\ lc = \ # of\ different\ circles\ *) \[IndentingNewLine]lc = Binomial[l, 3]; \[IndentingNewLine]circlelist = {}; \ \[IndentingNewLine]thiscircle = {1, 2, 3}; \[IndentingNewLine]\[IndentingNewLine]For[i = 1, i \[LessEqual] lc, \[IndentingNewLine]\[IndentingNewLine] (*\ orient\ the\ circle\ clockwise\ *) \[IndentingNewLine]cp\ = \ polpp[\([\ thiscircle\ ]\)]; \[IndentingNewLine]changeor\ = \ checkorient[\ cp\ ]; \[IndentingNewLine]If[\ changeor\ \[Equal] \ \(-1\), \ \[IndentingNewLine]ocircle\ = \ thiscircle[\([\ {1, 3, 2}\ ]\)], \[IndentingNewLine]ocircle\ = \ thiscircle\[IndentingNewLine]]; \[IndentingNewLine]\ \[IndentingNewLine]cp\ = \ polpp[\([\ ocircle\ ]\)]; \[IndentingNewLine]otherpoints = Complement[rr, ocircle]; \[IndentingNewLine] (*\ \ \(Print[ ocircle, \ \ otherpoints];\)\ \ *) \[IndentingNewLine]j\ = 1; \[IndentingNewLine]empty\ = \ True; \[IndentingNewLine]\[IndentingNewLine]While[\((\ j \[LessEqual] \((l - 3)\)\ && \ empty\ \[Equal] \ True)\), \[IndentingNewLine]h = otherpoints[\([j]\)]; \[IndentingNewLine]tocheck\ = \ Append[\ ocircle, h]; \[IndentingNewLine]If[\ psign[\ circledet[\ polpp[\([\ tocheck\ ]\)]\ ]\ ]\ \[Equal] \ 1, \[IndentingNewLine]\(j++\), \[IndentingNewLine]empty\ = \ False\[IndentingNewLine]];\[IndentingNewLine]]; \ \[IndentingNewLine]\[IndentingNewLine]If[\ empty\ \[Equal] \ True, \ \[IndentingNewLine]\(circlelist\ \ = \ Append[\ circlelist, ocircle\ ];\)\[IndentingNewLine]]; \[IndentingNewLine]\ \[IndentingNewLine] (*\ Use\ the\ undocumented\ function\ `NextKSubset'\ \ *) \[IndentingNewLine] (*\ \(Print["\", \ thiscircle];\)\ *) \[IndentingNewLine]thiscircle = NextKSubset[rr, thiscircle]; \[IndentingNewLine]\(i++\);\[IndentingNewLine]]; \ \[IndentingNewLine]circlelist\[IndentingNewLine]]\)], "Input", PageWidth->WindowWidth, InitializationCell->True], Cell[BoxData[ \(firstcoefpoly[function_] := Module[\[IndentingNewLine] (*\ Finds\ the\ coefficient\ belonging\ to\ the\ term\ of\ lowest\ \ degree\ *) \[IndentingNewLine]{depth = 0, coef = 0}, \[IndentingNewLine]If[ function \[Equal] 0, Return[0]]; \[IndentingNewLine]While[ coef \[Equal] 0, \(depth++\); \[IndentingNewLine]coef = Coefficient[function, t, depth];]; \[IndentingNewLine]coef]\)], "Input", PageWidth->WindowWidth, InitializationCell->True], Cell[BoxData[ RowBox[{ RowBox[{ StyleBox[ RowBox[{ StyleBox["p", Background->None], "sign"}]], "[", "exp_", "]"}], " ", ":=", " ", \(Module[\n\ \ {}, \[IndentingNewLine]If[\ NumberQ[exp], \ Return[\ Sign[exp]\ ]\[IndentingNewLine]]; \[IndentingNewLine]If[ PolynomialQ[exp], Return[\ Sign[\ firstcoefpoly[ exp]]]]; \[IndentingNewLine]False\n\t\t]\)}]], "Input", PageWidth->WindowWidth, InitializationCell->True], Cell[BoxData[ \(n2[p_]\ := \ p[\([1]\)]^2\ + \ p[\([2]\)]^2\)], "Input", PageWidth->WindowWidth, InitializationCell->True], Cell[BoxData[ \(linedet[pp_]\ := \ Module[\[IndentingNewLine]{mat, i}, \[IndentingNewLine]mat\ = \ Table[Prepend[\ pp[\([i]\)], 1], {i, 3}]; \[IndentingNewLine]Det[ mat]\[IndentingNewLine]]\)], "Input", PageWidth->WindowWidth, InitializationCell->True], Cell[BoxData[ \(circledet[pp_]\ := \ Module[\[IndentingNewLine]{mat, i}, \[IndentingNewLine]mat\ = \ Table[Join[\ pp[\([i]\)], \ {n2[\ \ pp[\([i]\)]\ \ ], 1}\ ], {i, 1, 4}]; \[IndentingNewLine]Det[mat]\[IndentingNewLine]]\)], "Input",\ PageWidth->WindowWidth, InitializationCell->True], Cell[BoxData[ \(bilineeq[{u_, v_}] := Module[\[IndentingNewLine]{rmat, b, a, pp}, \[IndentingNewLine]rmat\ = \ {{0, \(-1\)}, {1, 0}}; \[IndentingNewLine]b\ = \ \((1/2)\) \((u + v)\); \[IndentingNewLine]a\ = \ b\ + rmat . \((u - b)\); \[IndentingNewLine]pp = {b, a, {x, y}}; \[IndentingNewLine]mat = Table[Prepend[pp\[LeftDoubleBracket]i\[RightDoubleBracket], 1], {i, 3}]; \[IndentingNewLine]Det[mat]\[IndentingNewLine]]\)], "Input",\ InitializationCell->True] }, Closed]], Cell[CellGroupData[{ Cell["Example: computing the type.", "Subsection", PageWidth->WindowWidth], Cell["\<\ The sign of the matrix is \t0 p3 on line(p1,p2) \t1 p3 left of line(p1,p2) -1 p3 right of line(p1,p2)\ \>", "Text", PageWidth->WindowWidth], Cell[BoxData[{ \(linedet[\ {{1, 1}, {3, 3}, {2, 2}}]\), "\[IndentingNewLine]", \(linedet[{{1, 1}, {3, 3}, {0, 2}}]\), "\[IndentingNewLine]", \(linedet[{{1, 1}, {3, 3}, {2, 0}}]\)}], "Input", PageWidth->WindowWidth], Cell["\<\ The sign of the matrix is \t0\tp4 on circle(p1,p2,p3) \t-1 p4 in clockwise oriented circle(p1,p2,p3) \t1 p4 out clockwise oriented circle(p1,p2,p3)\ \>", "Text", PageWidth->WindowWidth], Cell[BoxData[{ \(circledet[{{\(-1\), 0}, {0, 1}, {1, 0}, {Cos[Pi/12], Sin[Pi/12]}}]\), "\[IndentingNewLine]", \(circledet[{{\(-1\), 0}, {0, 1}, {1, 0}, { .1, .1}}]\), "\[IndentingNewLine]", \(circledet[{{\(-1\), 0}, {0, 1}, {1, 0}, {3, 0}}]\)}], "Input", PageWidth->WindowWidth], Cell[TextData[{ "The orientation of the circle is essential. Therefore the three points \ defining the circle, should be in the right cyclic order. This can be \ achieved as follows: pick two points p_i and p_j. These two points determine \ a directed line l_ij. Determine", StyleBox[" s = signum[ linedet[{pi,pj,pk}] ]. ", FontFamily->"Courier"], "If\n\n\t s = -1 pi, pj, pk\n\t s = 1 pi, pk, pj\n\t\ s = 0 no general position" }], "Text", PageWidth->WindowWidth], Cell["We define some polynomial sites.", "Text", PageWidth->WindowWidth], Cell[BoxData[{ \(\(p3\ = \ {2\ t, \ 2\ t^3 + \ t^4};\)\), "\[IndentingNewLine]", \(\(p8\ = \ {\(-2\) t\ - \ t^3, \ 2\ t};\)\), "\[IndentingNewLine]", \(\(p11 = \ \ {\(-2\) t^2\ - 2\ t^4, \ \(-3\) t\ + \ 2\ t^2 - t^3\ };\)\), "\[IndentingNewLine]", \(\(p16\ = \ {t^2 - 2 t^3 + t^5, \(-t^4\)};\)\), "\[IndentingNewLine]", \(\(sites\ = \ {p3, p8, p11, p16};\)\)}], "Input", PageWidth->WindowWidth], Cell["\<\ We determine the orientation of the circle defined by p3, p8 and \ p11.\ \>", "Text", PageWidth->WindowWidth], Cell[BoxData[{ \(ld = linedet[{\ p3, \ p8, \ p11}]\), "\[IndentingNewLine]", \(psign[ld]\)}], "Input", PageWidth->WindowWidth], Cell[BoxData[ \(checkorient[{\ p3, \ p8, \ p11}]\)], "Input", PageWidth->WindowWidth], Cell["\<\ In this case, -1 means False, so the right orientation is p3, p11, \ p8. Now we can check if p16 in circle(p3, p11, p8) for small t.\ \>", "Text", PageWidth->WindowWidth], Cell[BoxData[{ \(cdet = circledet[{p3, p11, p8, p16}]\), "\[IndentingNewLine]", \(psign[cdet]\)}], "Input", PageWidth->WindowWidth], Cell[TextData[{ "Indeed, p16 is in the circle(p3, p11, p8). The program ", StyleBox["emptycircles[ polpp_List ]", FontFamily->"Courier"], " returns all empty circles of a list S of polynomial sites. By definition, \ this is the type of the Voronoi diagram V(S)." }], "Text", PageWidth->WindowWidth], Cell[BoxData[ \(emptycircles[\ sites]\)], "Input", PageWidth->WindowWidth], Cell["Let's try a bigger example.", "Text", PageWidth->WindowWidth], Cell[BoxData[ \(\(punten = {{0, t\^5}, {0, 2\ t + t\^4 + 2\ t\^5}, {2\ t, 2\ t\^3 + t\^4}, {t\^2, 2\ t + 2\ t\^2 - t\^3}, {\(-2\)\ t\^4, \(-t\^5\)}, {3\ t\^5, t\^2 + 2\ t\^3 + 3\ t\^5}, {2\ t + 3\ t\^2 - 2\ t\^3, 2\ t - 2\ t\^2 - t\^3}, {\(-2\)\ t - t\^3, 2\ t}, {\(-2\)\ t + t\^3, \(-2\)\ t - t\^3}, {t + 2\ t\^2 + 2\ t\^3, \(-t\) + 3\ t\^3}, {\(-2\)\ t\^2 - 2\ t\^4, \(-3\)\ t + 2\ t\^2 - t\^3 + t\^4}, {\(-2\)\ t - t\^4, 3\ t\^2 + 3\ t\^3 - t\^5}, {\(-2\)\ t\^2 - t\^4, \(-2\)\ t\^2 + 3\ t\^3}, {\(-t\) + 3\ t\^2 - 2\ t\^3 + 3\ t\^4, t + 3\ t\^2 - 3\ t\^5}, {\(-t\) - 2\ t\^5, \(-3\)\ t\^3 + 2\ t\^5}, {t\^2 - 2\ t\^3 + t\^5, \(-t\^4\)}, {3\ t\^3 + 2\ t\^5, \(-t\^4\)}, {3\ t\^3 + 3\ t\^4 + 2\ t\^5, 2\ t - 2\ t\^3 - t\^4}, {t\^2 + t\^3 + 3\ t\^5, 0}, {3\ t\^2 + 2\ t\^3 + 3\ t\^5, t\^2 + 3\ t\^3 + 2\ t\^4}};\)\)], "Input", PageWidth->WindowWidth], Cell[BoxData[ \(type20 = emptycircles[punten\ ]\)], "Input", PageWidth->WindowWidth], Cell["\<\ From every Voronoi vertex (= circle centre), three edges \ leave.\ \>", "Text", PageWidth->WindowWidth], Cell[BoxData[ \(ctoe[{1, 5, 6}]\)], "Input", PageWidth->WindowWidth], Cell[BoxData[ \(alledges = Flatten[Table[ctoe[type20[\([i]\)]], {i, Length[type20]}], 1]\)], "Input", PageWidth->WindowWidth], Cell["\<\ From this edge list, we can easily distill the unbounded \ edges.\ \>", "Text", PageWidth->WindowWidth], Cell[BoxData[ \(Table[ Length[\ Position[alledges, alledges[\([i]\)], 1]], {i, 1, \ Length[alledges]}]\)], "Input", PageWidth->WindowWidth], Cell[BoxData[ \(unbedges[\ alledges]\)], "Input", PageWidth->WindowWidth], Cell["\<\ These are edges between polynomial sites on the `combinatorial \ convex hull'.\ \>", "Text", PageWidth->WindowWidth], Cell["We can compute the actual centers of the Voronoi circles.", "Text", PageWidth->WindowWidth], Cell[BoxData[ \(cccc = Table[circlecenter[\ punten[\([\ type20[\([i]\)]\ ]\)]\ ], {i, Length[type20]}]\)], "Input", PageWidth->WindowWidth], Cell["\<\ By orienting the combinatorial convex hull in the rigth way and by \ analysing the (limit) direction, this gives us all information we need in \ order to construct the one-skeleton + multiplicities.\ \>", "Text", PageWidth->WindowWidth] }, Closed]], Cell[CellGroupData[{ Cell["Example: computing a circle center.", "Subsection", PageWidth->WindowWidth], Cell[BoxData[{ \(\(u = \ {0, \(-t\)};\)\), "\[IndentingNewLine]", \(\(v = {\(-t\), 0};\)\), "\[IndentingNewLine]", \(\(w\ = \ {t - t^2, \(-2\)\ t};\)\)}], "Input"], Cell["\<\ Computing the circle center, using the `circular' \ determinants.\ \>", "Text"], Cell[BoxData[ \(circlecenter[{u, v, w}]\)], "Input"], Cell["Alternatively, we construct equations in t for the bisectors", "Text"], Cell[BoxData[{ \(eq1 = bilineeq[{u, v}]\), "\[IndentingNewLine]", \(eq1\ = \ Expand[eq1/t]\), "\[IndentingNewLine]", \(sol = Solve[eq1 \[Equal] 0, y]\), "\[IndentingNewLine]", \(s1\ = \ sol[\([1, 1, 2]\)]\)}], "Input"], Cell[BoxData[{ \(eq2 = bilineeq[{u, w}]\), "\[IndentingNewLine]", \(eq2 = Expand[eq2/t]\), "\[IndentingNewLine]", \(sol\ = \ Solve[eq2 \[Equal] 0, y]\), "\[IndentingNewLine]", \(s2 = sol[\([1, 1, 2]\)]\)}], "Input"], Cell["And intersect them for finding the circle center.", "Text"], Cell[BoxData[{ \(sol2 = Solve[s1 \[Equal] s2, x]\), "\[IndentingNewLine]", \(s3\ = \ sol2[\([1, 1, 2]\)]\)}], "Input"], Cell[BoxData[{ \(sx\ = \ s3\ /. \ {\ t\ \[Rule] \ 0}\), "\[IndentingNewLine]", \(sy\ = \ s1\ /. \ {x\ \[Rule] \ sx}\)}], "Input"] }, Closed]] }, FrontEndVersion->"4.0 for X", ScreenRectangle->{{0, 1280}, {0, 1024}}, AutoGeneratedPackage->None, WindowSize->{710, 945}, WindowMargins->{{Automatic, -3}, {Automatic, 3}}, PrintingPageRange->{Automatic, Automatic}, PrintingOptions->{"PaperSize"->{597.562, 842.375}, "PaperOrientation"->"Portrait", "PostScriptOutputFile":>FrontEnd`FileName[{$RootDirectory, "user1", "home6", \ "Lindenbergh", "doc", "voronoi", "config", "notebooks"}, "seriestype.nb.ps", \ CharacterEncoding -> "ISO8859-1"], "Magnification"->1}, Magnification->1.25 ] (*********************************************************************** 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, 61, 1, 56, "Subsection"], Cell[1803, 54, 96, 3, 37, "Input", InitializationCell->True], Cell[1902, 59, 662, 13, 253, "Input", InitializationCell->True], Cell[2567, 74, 745, 14, 325, "Input", InitializationCell->True], Cell[3315, 90, 304, 7, 109, "Input", InitializationCell->True], Cell[3622, 99, 443, 9, 205, "Input", InitializationCell->True], Cell[4068, 110, 2781, 49, 1165, "Input", InitializationCell->True], Cell[6852, 161, 527, 10, 205, "Input", InitializationCell->True], Cell[7382, 173, 538, 14, 181, "Input", InitializationCell->True], Cell[7923, 189, 132, 3, 37, "Input", InitializationCell->True], Cell[8058, 194, 290, 6, 133, "Input", InitializationCell->True], Cell[8351, 202, 329, 7, 133, "Input", InitializationCell->True], Cell[8683, 211, 570, 11, 229, "Input", InitializationCell->True] }, Closed]], Cell[CellGroupData[{ Cell[9290, 227, 76, 1, 35, "Subsection"], Cell[9369, 230, 199, 6, 105, "Text"], Cell[9571, 238, 230, 4, 85, "Input"], Cell[9804, 244, 225, 6, 105, "Text"], Cell[10032, 252, 317, 6, 85, "Input"], Cell[10352, 260, 514, 10, 172, "Text"], Cell[10869, 272, 74, 1, 39, "Text"], Cell[10946, 275, 454, 8, 133, "Input"], Cell[11403, 285, 121, 4, 39, "Text"], Cell[11527, 291, 137, 3, 61, "Input"], Cell[11667, 296, 91, 2, 37, "Input"], Cell[11761, 300, 182, 4, 61, "Text"], Cell[11946, 306, 142, 3, 61, "Input"], Cell[12091, 311, 310, 7, 84, "Text"], Cell[12404, 320, 80, 2, 37, "Input"], Cell[12487, 324, 69, 1, 39, "Text"], Cell[12559, 327, 1062, 17, 247, "Input"], Cell[13624, 346, 90, 2, 37, "Input"], Cell[13717, 350, 115, 4, 39, "Text"], Cell[13835, 356, 74, 2, 37, "Input"], Cell[13912, 360, 147, 4, 37, "Input"], Cell[14062, 366, 115, 4, 39, "Text"], Cell[14180, 372, 160, 4, 61, "Input"], Cell[14343, 378, 79, 2, 37, "Input"], Cell[14425, 382, 128, 4, 39, "Text"], Cell[14556, 388, 99, 1, 39, "Text"], Cell[14658, 391, 163, 4, 61, "Input"], Cell[14824, 397, 248, 5, 61, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[15109, 407, 83, 1, 35, "Subsection"], Cell[15195, 410, 178, 3, 85, "Input"], Cell[15376, 415, 89, 3, 39, "Text"], Cell[15468, 420, 56, 1, 37, "Input"], Cell[15527, 423, 76, 0, 39, "Text"], Cell[15606, 425, 239, 4, 109, "Input"], Cell[15848, 431, 235, 4, 109, "Input"], Cell[16086, 437, 65, 0, 39, "Text"], Cell[16154, 439, 128, 2, 61, "Input"], Cell[16285, 443, 144, 2, 61, "Input"] }, Closed]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)