Skip to main content
. 2017 Oct 10;17(10):2304. doi: 10.3390/s17102304
Algorithm 2 Division Calculation
Input: A continuous area A, m circles {c1,c2,,cm} on A.
Output: All divisions within A.
  • 1:

    Cirs={c1,c2,,cm},Arcs=,Divs=,DivCmps=;

  • 2:

    Calculate all the intersection points on ciCirs and A¯, and record the list of intersection points on ci;

  • 3:

    Add all the arcs in A¯ to Arcs if A¯ has intersection points;

  • 4:

    for all ciCirs do

  • 5:

    if ci has no intersection point and is inside A then

  • 6:

      Add ci to DivCmps and then to Divs;

  • 7:

    else

  • 8:

      Add all arcs on ci and inside A to Arcs;

  • 9:

    for all arcsrcArcsA¯ do

  • 10:

    arccur=arcsrc;

  • 11:

    repeat

  • 12:

      Select arcnextArcs such that arcnext share the endpoint end1(arccur) and the angle from arcnext to arccur is minimized;

  • 13:

      arccur = arcnext;

  • 14:

    until (arccur == arcsrc)

  • 15:

    if the chain d1 of arcs form the profile of multiple circles then

  • 16:

      Add d1 to DivCmps if d1DivCmps;

  • 17:

    else

  • 18:

      Add d1 to Divs if d1Divs;

  • 19:

    arccur=arcsrc;

  • 20:

    repeat

  • 21:

      Select arcnextArcs such that arcnext share the endpoint end2(arccur) and the angle from arcnext to arccur is minimized;

  • 22:

      arccur = arcnext;

  • 23:

    until (arccur == arcsrc)

  • 24:

    if the chain d2 of arcs form the profile of multiple circles then

  • 25:

      Add d2 to DivCmps if d2DivCmps;

  • 26:

    else

  • 27:

      Add d2 to Divs if d2Divs;

  • 28:

    if there is no intersection point in A¯ then

  • 29:

    if Divs or A is inside a circle then

  • 30:

      Add A¯ to Divs;

  • 31:

    for all diDivCmps do

  • 32:

    dmin=;

  • 33:

    for all djDivs do

  • 34:

      if dj encloses di and (dmin= or d encloses dj) then

  • 35:

       dmin=dj;

  • 36:

     Incorporate di into dmin and update dmin in Divs;

  • 37:

    return Divs.