Polyhedral Maps

NetOfConvexPolyhedron[lica_, ogli_] := 
  Module[{ogli1, lica2, lica1, parilic, tr1, tr2, lica3}, 
   lica1 = lica; ogli1 = ogli; lica2 = Pretvorba[lica1]; 
    parilic = AdjacencyPairsHI[lica2]; 
    tr1 = TreeHI[parilic][1][Length[lica2]]; tr2 = UrediTree2HI[tr1]; 
    lica3 = ChangeOrientation[tr2][lica2]; 
    NetOfConvex[lica3, tr2, ogli1][{0.1, 0.13}]]
 
Pretvorba[seznam_] := 
  Module[{len = Length[seznam], izhod}, 
   (izhod = Table[{}, {len}]; Do[ln = Length[seznam[[k]]]; 
        Do[izhod[[k]] = Append[izhod[[k]], seznam[[k]][[i]][[1]][[1]]], 
         {i, 1, ln}], {k, 1, len}]); izhod]
 
AdjacencyPairsHI[lis_] := 
  Cases[Union @@ 
    Table[{a, b}, {a, 1, Length[lis] - 1}, {b, a + 1, Length[lis]}], 
   {x_, y_} /; AdjacentHI[lis][x, y]]
 
AdjacentHI[lis_][a_, b_] := Length[Intersection[lis[[a]], lis[[b]]]] == 2
 
TreeHI[pove_][n_][m_] := 
  Module[{tr = {pove[[n]]}}, While[ !MaksiTreeHIQ[tr, m], 
     Do[If[DodajHIQ[tr, pove[[k]]], tr = Append[tr, pove[[k]]]; Break[]], 
      {k, 1, Length[pove]}]]; tr]
 
MaksiTreeHIQ[tr_, n_] := 
  Module[{flag = True}, Do[If[NiNode[i][tr], flag = False; Break[]], 
     {i, 1, n}]; flag]
 
NiNode[a_][seznam_] := 
  Module[{flag = True}, Do[If[a == seznam[[i]][[1]] || 
       a == seznam[[i]][[2]], flag = False; Break[]], {i, 1, Length[seznam]}]\
; flag]
 
DodajHIQ[tr_, {a_, b_}] := 
  JeNode[a][tr] && NiNode[b][tr] || JeNode[b][tr] && NiNode[a][tr]
 
JeNode[a_][seznam_] := MemberQ[seznam, {a, x_}] || MemberQ[seznam, {y_, a}]
 
UrediTree2HI[drevo_] := 
  Module[{drev = drevo, len = Length[drevo]}, 
   Do[Do[If[drev[[k]][[2]] == drev[[i]][[2]], 
       drev = ReplacePart[drev, {drev[[k]][[2]], drev[[k]][[1]]}, k]], 
      {i, 1, k - 1}], {k, 2, len}]; drev]
 
ChangeOrientation[pari_][lica_] := 
  Module[{nnov, nprej, n, len = Length[lica], ai, zi, indlicap, indlican, 
    licep, licen, presek, p1, p2, q1, q2, a1, ainov, r1, r2, aiprej, 
    aikompl, aizaceten, qq1, uni1, uni2, newfaces = lica, avindex, edges, 
    q1n, q2n}, Do[indlicap = pari[[m]][[1]]; indlican = pari[[m]][[2]]; 
      nnov = Length[lica[[indlican]]]; nprej = Length[lica[[indlicap]]]; 
      licep = newfaces[[indlicap]]; licen = newfaces[[indlican]]; 
      presek = Intersection[licep, licen]; 
      {{p1}} = Position[licep, presek[[1]]]; 
      {{p2}} = Position[licep, presek[[2]]]; 
      {{q1}} = Position[licen, presek[[1]]]; 
      {{q2}} = Position[licen, presek[[2]]]; q1n = q1; q2n = q2; 
      If[PrejQHI[nprej][p1, p2] && PrejQHI[nnov][q1, q2] || 
        PrejQHI[nprej][p2, p1] && PrejQHI[nnov][q2, q1], 
       newfaces = ReplacePart[newfaces, Reverse[licen], indlican]; 
        q1n = nnov - q1; q2n = nnov - q2]; 
      newfaces = 
       ReplacePart[newfaces, If[PrejQHI[nnov][q1n, q2n], 
         RotateLeft[newfaces[[indlican]], q1n - 1], 
         RotateLeft[newfaces[[indlican]], q2n - 1]], indlican], 
     {m, 1, len - 1}]; newfaces]
 
PrejQHI[n_][p_, q_] := q == p + 1 || p == n && q == 1
 
NetOfConvex[afaces_, facetree_, vertis_][{a_, b_}] := 
  Module[{linijaset, linija, poin1, poin2, d1, d2, len, p1, p2, indn, indp, 
    indlica, novatocka, len1, maksi}, 
   linijaset = Table[{}, {Length[afaces]}]; 
    maksi = Table[0, {Length[afaces]}]; linija = {}; poin1 = {a, b}; 
    indlica = facetree[[1,1]]; maksi = 
     ReplacePart[maksi, Max[afaces[[indlica]]], indlica]; 
    linija = Append[linija, poin1]; 
    d1 = DistanceHI[vertis[[afaces[[indlica,1]]]], 
      vertis[[afaces[[indlica,2]]]]]; poin2 = {poin1[[1]] + d1, poin1[[2]]}; 
    linija = Append[linija, poin2]; len = Length[afaces[[indlica]]]; 
    Do[d1 = DistanceHI[vertis[[afaces[[indlica,1]]]], 
        vertis[[afaces[[indlica,i]]]]]; 
      d2 = DistanceHI[vertis[[afaces[[indlica,2]]]], 
        vertis[[afaces[[indlica,i]]]]]; 
      novatocka = TwoCirclesIntersectionNewHI[poin1, poin2, {d1, d2}]; 
      linija = Append[linija, novatocka], {i, 3, len}]; 
    linija = Append[linija, poin1]; 
    linijaset = ReplacePart[linijaset, linija, indlica]; 
    len1 = Length[facetree]; linija = {}; 
    Do[indn = facetree[[i,2]]; indp = facetree[[i,1]]; 
      maksi = ReplacePart[maksi, Max[afaces[[indn]]], indn]; 
      {{p1}} = Position[afaces[[indp]], afaces[[indn,1]]]; 
      {{p2}} = Position[afaces[[indp]], afaces[[indn,2]]]; linija = {}; 
      poin1 = linijaset[[indp,p1]]; poin2 = linijaset[[indp,p2]]; 
      linija = Append[linija, poin1]; linija = Append[linija, poin2]; 
      len = Length[afaces[[indn]]]; 
      Do[d1 = DistanceHI[vertis[[afaces[[indn,1]]]], 
          vertis[[afaces[[indn,k]]]]]; 
        d2 = DistanceHI[vertis[[afaces[[indn,2]]]], 
          vertis[[afaces[[indn,k]]]]]; 
        novatocka = TwoCirclesIntersectionNewHI[poin1, poin2, {d1, d2}]; 
        linija = Append[linija, novatocka], {k, 3, len}]; 
      linija = Append[linija, linijaset[[indp,p1]]]; 
      linijaset = ReplacePart[linijaset, linija, indn], {i, 1, len1}]; 
    {linijaset, maksi}]
 
DistanceHI[{a_, b_, c_}, {x_, y_, z_}] := 
  N[Sqrt[(a - x)^2 + (b - y)^2 + (c - z)^2]]
 
TwoCirclesIntersectionNewHI[{x1_, y1_}, {x2_, y2_}, {r1_, r2_}] := 
  Module[{c, a, b, e}, c = Sqrt[(x2 - x1)^2 + (y2 - y1)^2]; a = r2; b = r1; 
    e = ({x2, y2} - {x1, y1})/c; ConstructTriangleHI[{x1, y1}, e][a, b, c]]
 
ConstructTriangleHI[{x1_, y1_}, e_][a_, b_, c_] := 
  Module[{p, hc, cosa, AB, x2, y2, x3, y3}, 
   p = (a + b + c)/2; hc = 2*Sqrt[p*(p - a)*(p - b)*(p - c)]/c; 
    cosa = (b^2 + c^2 - a^2)/(2*b*c); AB = c*e; {x2, y2} = {x1, y1} + AB; 
    {x3, y3} = {x1, y1} + b*cosa*e + OrtAB[AB]*hc; {x3, y3}]
 
OrtAB[{x_, y_}] := {-y, x}/Sqrt[x^2 + y^2]

navEurasia={{{31.3333,34.2167},{33.1,35.1},{34.65,35.9667},{35.9333,35.9167},{36.9333,36.0167},{36.0167,32.8},{36.1167,29.6833},{36.6833,27.3667},{37.0333,28.3333},{38.2667,26.2333},{38.45,27.1667},{39.95,26.15},{41.1833,29.6167},{42.1,34.95},{41.5167,41.5333},{43.3833,40.},{45.0333,36.3667},{44.4333,33.6333},{45.4,32.4833},{45.9333,33.7667},{46.2833,31.8},{47.25,31.75},{45.2167,29.6667},{43.75,28.5833},{41.9833,28.0167},{41.,28.9833},{40.05,26.1833},{40.7333,26.0333},{40.7167,23.7},{40.4667,22.5833},{38.85,22.5167},{38.2,24.0667},{37.5667,22.7167},{36.4333,23.2},{37.85,21.1},{38.1833,22.2167},{38.15,23.2333},{39.2833,20.3833},{39.6833,20.0167},{41.853,19.3665},{42.3667,18.65},{45.3,14.5667},{45.6,13.7167},{45.45,12.2667},{44.2167,12.3833},{40.1333,18.5167},{40.1,16.6167},{37.9167,16.0667},{40.0333,15.6667},{42.4,11.1},{44.0167,10.1},{43.7833,7.53333},{43.55,3.88333},{42.4333,3.21667},{39.95,0.},{38.9333,-0.116667},{38.6167,0.},{36.7333,-2.13333},{36.15,-5.36667},{37.1833,-7.41667},{37.1833,-8.91667},{38.7167,-9.5},{41.9667,-8.75},{43.0667,-9.28333},{43.7833,-7.9},{43.4,-1.76667},{46.3167,-1.11667},{48.5167,-4.78333},{48.6333,-1.35},{49.7333,-1.93333},{49.3333,0.},{51.0833,2.55},{51.3667,3.36667},{52.9667,4.73333},{53.2333,7.2},{53.5333,9.83333},{54.9167,8.66667},{56.5833,8.13333},{57.05,9.95},{56.8167,8.25},{57.7333,10.55},{54.8167,9.45},{53.95,10.9},{53.9333,14.2333},{54.4667,19.6333},{54.95,21.25},{55.3333,21.2833},{56.05,21.3333},{57.2,21.4167},{57.2333,24.4},{57.8667,24.1},{59.2167,23.4667},{59.4833,28.0333},{59.9667,30.25},{60.5667,27.85},{59.8,22.8833},{60.5833,21.4167},{62.7667,21.1},{64.95,25.45},{65.8167,24.1667},{62.4833,17.3333},{59.7333,19.0833},{59.5,16.0167},{59.1333,18.4167},{58.6333,16.1833},{56.0833,15.85},{55.3333,13.3},{58.9833,11.4333},{59.8833,10.5667},{58.0667,6.6},{59.5,5.18333},{60.5,7.1},{60.65,5.18333},{61.2333,7.7},{61.1,5.2},{61.8667,6.81667},{62.1833,5.08333},{62.9167,6.88333},{63.7833,11.45},{63.7667,9.55},{66.6667,13.1833},{69.3167,18.1},{70.9667,25.3667},{71.1167,27.65},{70.8667,29.1},{70.2833,31.0667},{69.7833,30.7833},{67.2,41.3667},{66.0833,37.9667},{67.1667,31.8833},{66.2,34.1667},{64.55,34.75},{64.3333,35.3333},{63.8167,37.5333},{65.1833,36.85},{64.5333,40.5},{65.6167,39.85},{65.8667,44.1833},{67.95,44.1333},{68.4667,46.},{67.35,44.9167},{66.8667,47.5667},{68.8667,53.2167},{68.3333,59.65},{69.2667,65.05},{68.3167,68.65},{71.05,66.6167},{72.6667,68.9833},{72.7,72.8333},{67.7167,73.15},{66.8,68.9667},{66.2167,72.},{68.9833,76.55},{67.5667,79.05},{68.9,77.6333},{69.1333,73.8},{70.4167,74.1667},{72.8833,75.},{71.5667,75.5},{70.8833,78.45},{71.5833,76.25},{72.4,78.5167},{71.7167,83.2667},{70.0833,83.1667},{73.5667,80.5167},{73.9,86.7833},{72.9833,86.7833},{74.7167,85.8667},{76.2667,98.8},{75.1667,100.183},{76.5,98.8167},{76.3833,102.25},{77.7333,104.067},{76.75,111.1},{75.4,113.717},{72.7833,105.067},{73.8667,111.3},{72.6167,113.617},{73.5,113.483},{73.5667,118.633},{70.7333,131.017},{71.4667,140.033},{72.9,140.65},{72.3167,146.933},{71.6667,144.883},{72.3167,148.267},{70.7833,152.533},{70.8167,159.25},{68.5333,161.05},{69.6667,162.433},{68.75,170.617},{69.8,170.55},{69.8833,176.117},{66.3,174.467},{67.1333,173.683},{66.1333,169.717},{65.7,172.85},{64.25,173.183},{66.4167,179.183},{64.8167,179.483},{64.6833,174.433},{64.45,178.183},{62.2833,179.1},{62.8667,176.983},{59.9167,170.25},{60.6167,169.217},{60.0333,163.633},{58.0667,161.933},{56.2,163.35},{54.7667,162.117},{50.8833,156.65},{56.6667,155.95},{62.45,165.65},{62.55,163.267},{61.1333,161.433},{60.5833,160.133},{61.7667,160.367},{61.8,157.483},{59.8833,154.233},{59.1667,155.183},{58.9,152.9},{59.7667,149.617},{59.2333,142.583},{54.9333,135.217},{54.3167,137.733},{53.5333,137.317},{54.3167,139.75},{53.2833,141.417},{48.45,140.183},{43.5,135.133},{43.3333,131.817},{42.2833,130.7},{39.7167,127.5},{38.6167,128.367},{35.4833,129.433},{34.2833,126.517},{37.8333,126.7},{38.1167,124.667},{38.6333,125.65},{40.1,124.367},{38.7167,121.183},{40.,121.883},{40.9833,121.867},{39.9833,119.867},{38.2833,117.783},{37.35,118.933},{37.4,122.7},{35.0667,119.283},{31.7333,121.9},{32.35,119.617},{30.9667,121.883},{30.2,120.15},{29.8833,122.133},{27.2167,120.433},{26.15,119.1},{23.6167,117.183},{22.2667,114.283},{23.1,113.4},{22.1833,113.55},{21.5167,111.633},{21.4333,110.35},{20.2333,109.917},{20.7167,109.85},{21.4833,109.95},{21.55,107.983},{19.6,105.783},{17.5667,106.583},{15.25,108.95},{11.7167,109.25},{9.58333,106.55},{10.,105.817},{8.56667,104.85},{10.4167,104.45},{11.6333,102.917},{12.65,100.867},{13.5167,100.267},{10.3667,99.15},{7.16667,100.417},{6.23333,102.1},{4.8,103.45},{1.45,104.3},{1.26667,103.517},{2.83333,101.283},{6.41667,100.133},{8.21667,98.2833},{10.35,98.75},{16.5667,97.7333},{17.45,96.8833},{15.95,95.6667},{15.9667,94.25},{19.3833,94.0833},{21.1333,92.2},{21.9167,89.0333},{22.4167,87.9},{19.9833,86.4167},{15.7,80.2833},{11.1667,79.85},{9.15,79.45},{8.4,76.9667},{16.5167,73.3},{22.2667,72.9167},{21.2,72.1167},{20.7167,70.7333},{22.3,68.95},{23.1,70.5},{23.7667,68.2},{25.1167,66.7},{25.2,61.6167},{25.6333,57.7833},{26.7,53.7167},{29.95,50.1333},{29.9667,48.5333},{30.0167,47.95},{28.55,48.4167},{24.75,50.8333},{26.15,51.25},{24.6167,51.2167},{24.1333,54.1167},{26.3833,56.3667},{24.5,56.6},{22.2167,59.8},{18.9667,57.8},{16.6333,53.0833},{14.0333,48.7},{12.7,43.55},{16.3833,42.7833},{21.1,39.1833},{28.0833,34.5667},{29.55,34.9667}}};

navAfrica={{{31.3333,34.2167},{31.65,25.15},{32.95,21.7167},{30.2833,19.3333},{31.3167,15.9167},{33.1667,11.5333},{34.1667,10.},{37.0833,11.05},{36.9333,8.61667},{35.8333,0.},{35.0833,-2.21667},{35.9167,-5.41667},{35.0167,-6.23333},{32.55,-9.28333},{29.3167,-10.2333},{27.6667,-13.1833},{20.7667,-17.05},{20.2167,-16.2},{16.05,-16.5333},{14.75,-17.5333},{13.5833,-16.5667},{13.45,-15.3},{13.0667,-16.75},{12.8333,-15.3833},{12.3167,-16.7167},{11.9667,-15.},{11.3333,-15.5},{10.95,-15.0167},{9.03333,-13.3},{6.93333,-11.4833},{4.35,-7.53333},{5.08333,-3.1},{5.61667,0.},{6.1,1.2},{6.21667,1.65},{6.36667,2.73333},{5.9,5.28333},{4.26667,6.1},{4.8,8.58333},{4.13333,9.75},{2.35,9.81667},{1.,9.8},{-0.633333,8.71667},{-3.95,11.1667},{-5.01667,12.0333},{-5.78333,12.2},{-5.86667,13.1833},{-6.1,12.25},{-11.8,13.8},{-17.25,11.7667},{-22.6833,14.5333},{-23.1333,14.45},{-28.5833,16.4833},{-34.1667,18.3167},{-34.8167,20.},{-33.0333,27.9},{-26.85,32.9},{-25.6,32.8167},{-24.1,35.5},{-19.6167,34.5667},{-15.2833,40.6667},{-10.4833,40.4333},{-6.05,38.7833},{-4.66667,39.2},{-1.66667,41.5667},{4.46667,47.95},{10.45,51.4167},{12.,50.7833},{10.4167,44.9167},{11.5167,43.2833},{11.5333,42.5167},{12.7167,43.1167},{15.0833,39.7167},{18.0333,38.6167},{22.0333,36.9},{23.1333,35.6167},{29.6,32.3333},{27.7333,34.25},{29.55,34.9667}}};

navAmericas={{{-34.5,-57.8333},{-32.45,-58.2},{-34.45,-58.5167},{-36.9,-56.6667},{-38.4833,-58.3167},{-38.8,-62.3833},{-40.8167,-62.3},{-40.85,-65.1333},{-42.6167,-63.5833},{-42.6667,-64.9667},{-45.0167,-65.6},{-46.,-67.5833},{-47.3833,-65.7333},{-50.0167,-69.0167},{-52.3833,-68.4333},{-53.3833,-72.1333},{-52.85,-71.1167},{-53.2333,-73.2167},{-52.6333,-71.4667},{-53.,-73.45},{-51.7833,-72.4667},{-52.05,-73.55},{-50.2,-74.7},{-48.0167,-74.65},{-48.,-73.2167},{-46.8,-74.5167},{-46.6333,-75.7},{-45.8,-74.1667},{-46.5333,-73.7333},{-44.5,-72.6},{-41.3833,-72.3},{-37.3333,-73.6833},{-32.65,-71.45},{-18.35,-70.4},{-14.1667,-76.2833},{-8.58333,-78.7667},{-6.,-81.1833},{-3.36667,-80.3333},{-2.01667,-79.7667},{-2.31667,-80.9167},{-1.03333,-80.9167},{1.43333,-78.8167},{3.91667,-77.0333},{7.23333,-77.8833},{8.55,-78.1167},{8.93333,-79.5333},{7.25,-80.4333},{8.03333,-82.9},{9.9,-85.6667},{11.0667,-85.6833},{12.9667,-87.3333},{13.4333,-87.8333},{13.75,-90.1},{14.55,-92.25},{16.4333,-94.8667},{15.9667,-97.7833},{18.3333,-103.483},{19.9167,-105.45},{22.5333,-105.717},{25.6333,-109.4},{28.9667,-112.167},{31.2333,-113.083},{31.95,-115.033},{28.2833,-112.867},{23.1333,-109.517},{24.7333,-112.1},{27.7333,-115.017},{28.5167,-114.067},{32.5333,-117.117},{33.,-117.283},{34.5667,-120.617},{37.5167,-122.483},{38.0167,-121.417},{38.9333,-123.7},{42.,-124.183},{46.2833,-124.067},{48.4,-124.717},{48.1667,-122.75},{47.1167,-123.067},{48.9833,-122.75},{50.9167,-124.817},{51.1667,-127.783},{51.6667,-127.883},{52.3667,-126.733},{52.3667,-128.333},{53.55,-128.967},{53.8833,-130.05},{55.9167,-130.017},{54.7667,-130.683},{56.1,-131.017},{55.75,-132.267},{59.4667,-135.333},{58.2,-135.15},{60.05,-139.5},{61.2833,-147.717},{59.85,-149.65},{59.2833,-151.983},{61.5,-149.25},{58.7167,-153.45},{56.,-158.433},{54.8,-163.333},{57.5,-157.4},{59.15,-156.783},{58.8833,-160.15},{58.65,-162.167},{60.7,-161.883},{59.8,-163.667},{60.9,-163.55},{61.45,-165.017},{61.5833,-166.2},{63.2167,-164.417},{63.5167,-161.15},{64.9333,-160.983},{65.65,-168.133},{66.6,-164.283},{65.9833,-161.8},{66.95,-162.483},{66.4,-160.233},{68.35,-166.833},{70.2,-161.733},{71.4,-156.467},{69.65,-141.017},{68.65,-135.167},{69.4667,-133.05},{70.2667,-129.667},{68.8833,-133.467},{69.35,-130.8},{70.5833,-128.},{69.3167,-125.433},{70.15,-124.55},{69.35,-124.333},{68.8667,-114.983},{67.8,-115.1},{68.,-110.083},{66.35,-107.25},{68.6333,-105.65},{68.1833,-108.45},{68.9333,-106.217},{67.6833,-102.233},{67.6167,-97.2},{68.55,-97.85},{67.7333,-96.1833},{66.5833,-95.8167},{67.6333,-95.4667},{68.6333,-93.3667},{70.1333,-96.5333},{72.,-94.5667},{69.6667,-92.9167},{68.2333,-90.25},{69.2333,-88.95},{67.25,-87.05},{69.8667,-85.5667},{69.1833,-81.3333},{67.,-81.5},{66.9167,-85.2167},{66.1833,-83.7},{65.3167,-87.4},{65.95,-91.5},{65.2333,-87.0333},{64.1833,-87.9833},{64.1833,-93.7833},{63.0667,-90.6333},{60.5,-94.8},{58.4833,-94.3},{56.9,-92.8833},{56.8333,-88.8333},{54.9833,-85.4167},{55.15,-82.3},{52.1833,-81.8833},{50.7167,-79.3333},{54.65,-79.7667},{55.65,-77.1333},{57.2333,-76.5833},{58.6167,-78.5667},{62.3333,-78.1},{61.7333,-72.0833},{60.9,-69.3667},{60.0667,-71.0333},{58.55,-68.2},{57.7667,-69.3667},{58.5833,-68.},{58.3167,-66.0667},{60.3667,-64.8333},{56.7167,-62.2},{55.,-60.6833},{54.5833,-57.35},{54.2333,-58.3667},{53.2667,-60.4167},{54.2333,-58.0333},{53.1833,-55.7667},{52.2167,-55.6167},{50.2,-60.1333},{50.3167,-64.4667},{48.1333,-69.6833},{48.4333,-71.0667},{48.1167,-69.7333},{46.75,-71.3},{49.2667,-65.45},{48.5,-64.2167},{48.,-66.85},{47.7333,-64.6833},{45.8333,-63.75},{45.8833,-61.9167},{45.2667,-60.9667},{43.4667,-65.4667},{44.4167,-66.1833},{45.3667,-63.3667},{45.35,-64.9333},{46.0833,-64.75},{45.2667,-65.7167},{45.1833,-67.2},{43.0667,-70.75},{41.5167,-71.1167},{41.3167,-71.85},{41.,-73.65},{40.5167,-74.25},{38.95,-74.85},{40.,-75.0333},{39.8,-75.4333},{38.45,-75.0333},{38.0167,-75.3667},{37.1333,-75.95},{37.9667,-75.65},{38.5167,-76.2333},{39.5833,-75.8333},{38.05,-76.3167},{38.8,-77.0167},{38.1667,-77.1333},{37.0833,-76.2667},{37.3167,-77.2833},{36.55,-75.85},{35.7833,-75.5167},{36.7167,-75.9333},{35.95,-76.7333},{35.6167,-75.75},{35.5333,-77.05},{34.8833,-76.3333},{33.85,-78.5333},{32.0167,-80.8833},{30.7167,-81.5},{26.7833,-80.0333},{25.25,-80.4167},{25.1167,-81.0833},{27.9167,-82.8333},{28.6667,-82.6667},{29.9167,-83.6833},{30.1,-84.},{29.6667,-85.3167},{30.4,-86.6667},{30.2833,-87.5167},{30.3833,-88.4},{30.1833,-89.5167},{29.25,-89.2},{29.1,-90.8667},{29.7,-93.8333},{27.8667,-97.5167},{25.9667,-97.1333},{22.6,-97.8833},{18.7167,-95.8667},{18.6667,-91.1833},{21.0333,-90.3333},{21.6167,-87.1167},{18.4833,-88.2833},{15.9,-88.9167},{15.7167,-88.2167},{15.,-83.1333},{10.9167,-83.65},{9.56667,-82.5667},{9.26667,-80.0333},{8.66667,-77.3667},{7.91667,-76.75},{11.1333,-74.8667},{11.85,-71.3167},{9.05,-71.6333},{10.8,-71.5833},{11.4333,-69.8},{12.2,-70.0167},{10.6833,-68.3},{10.0333,-65.0833},{10.75,-61.85},{10.1,-63.0167},{9.43333,-60.85},{8.56667,-61.6167},{8.53333,-59.9833},{7.36667,-58.4833},{6.38333,-58.6833},{5.48333,-57.25},{5.35,-54.1667},{5.45,-52.9333},{4.03333,-51.6833},{1.16667,-49.8833},{-1.6,-52.7167},{-0.916667,-50.85},{-1.78333,-50.7167},{-1.78333,-49.4167},{-2.68333,-49.6833},{-1.78333,-48.9333},{-0.716667,-46.8167},{-1.75,-44.6},{-3.3,-44.7833},{-2.85,-40.},{-5.21667,-35.4167},{-8.35,-34.9333},{-12.7333,-38.15},{-12.7333,-38.9167},{-13.7167,-38.9833},{-17.6833,-39.1333},{-21.9833,-40.9667},{-25.35,-48.75},{-28.5333,-48.75},{-32.1667,-52.0667},{-30.45,-50.5667},{-30.0167,-51.2833},{-33.75,-53.3667},{-34.5,-57.8333}}};

navIslands1={
{{66.1333,-35.8167},{68.6167,-32.4833},{68.5333,-27.2167},{70.,-22.3},{70.4,-29.2},{71.2667,-25.4167},{72.1333,-28.6},{70.4667,-21.5667},{72.4,-25.55},{73.45,-27.45},{73.45,-20.5},{74.5833,-22.1167},{74.4833,-18.9833},{75.1667,-22.4333},{75.4,-19.3333},{76.8333,-22.4667},{76.95,-18.1167},{77.6833,-22.0333},{80.5,-16.1167},{80.5667,-21.25},{81.6,-12.15},{80.5333,-24.4667},{82.0833,-22.3},{82.,-25.2333},{81.6833,-32.65},{82.6,-21.3167},{82.75,-35.4833},{83.2833,-25.6667},{83.6167,-33.0167},{83.0167,-46.6833},{82.6667,-39.9},{82.7667,-45.75},{81.75,-44.6333},{81.6167,-49.8667},{82.1,-58.5833},{81.3333,-56.45},{81.9333,-60.1333},{79.1333,-65.8},{78.5,-72.6333},{77.5,-66.0667},{77.05,-71.3667},{76.0833,-68.5},{76.0167,-60.0833},{71.6833,-55.9},{72.35,-53.5667},{70.5167,-50.4833},{70.65,-54.6333},{70.0167,-50.2167},{68.3333,-53.3833},{67.9333,-50.15},{67.5333,-53.7333},{67.9,-50.9667},{67.2333,-53.8667},{67.1667,-50.3667},{67.0667,-53.9667},{66.1,-53.4833},{66.9833,-50.},{65.9833,-53.4667},{65.7167,-50.55},{65.3167,-52.5667},{64.2,-52.},{64.8667,-50.},{63.3833,-50.4667},{60.8167,-48.2333},{61.2,-45.2167},{60.0667,-45.1167},{60.1,-43.1},{61.7333,-42.4667},{62.75,-43.15},{65.1167,-41.1167},{66.1333,-35.8167}},
{{63.85,-21.3667},{64.8667,-24.05},{65.45,-21.7},{65.5,-24.5333},{66.4333,-23.1167},{65.1667,-21.0833},{66.5333,-16.1667},{65.4667,-13.6333},{63.4667,-18.1667},{63.85,-21.3667}},
{{58.6333,-5.},{58.6333,-3.01667},{57.5,-4.25},{57.6,-1.81667},{56.0167,-3.68333},{53.7667,0},{52.4833,1.76667},{51.45,0.383333},{50.7333,0.233333},{50.5833,-4.91667},{51.75,-2.38333},{51.6667,-4.3},{52.85,-4.71667},{53.3333,-2.73333},{54.9833,-3.01667},{54.85,-5.13333},{56.2667,-4.93333},{55.3,-5.81667},{58.6333,-5.}},
{{52.1833,-6.36667},{51.45,-9.76667},{52.1833,-10.4667},{52.6667,-8.73333},{54.1,-10.1167},{55.05,-7.25},{54.0833,-6.26667},{52.1833,-6.36667}},
{{-21.8667,43.3167},{-19.95,44.5167},{-16.1833,44.4667},{-14.7667,48.},{-11.95,49.2833},{-15.3167,50.5},{-15.55,49.6333},{-24.9833,47.1333},{-24.95,44.0667},{-21.8667,43.3167}},
{{7.6,79.8},{5.93333,80.4667},{7.28333,81.8833},{9.76667,79.9167},{9.45,80.6167},{7.6,79.8}},
{{32.45,131.65},{33.95,131.017},{33.35,129.583},{31.,130.667},{32.45,131.65}},
{{34.0833,134.6},{32.7,133.017},{33.3333,132.017},{34.0833,134.6}},
{{41.4333,141.133},{39.55,142.067},{35.1333,140.333},{34.6,138.85},{35.0833,136.85},{33.4333,135.767},{34.7167,135.333},{33.9333,130.883},{35.5833,133.083},{37.35,136.767},{37.3667,138.55},{41.4333,141.133}},
{{45.5167,141.95},{44.1,143.767},{43.3667,145.817},{41.9167,143.233},{42.5667,140.467},{41.8,141.2},{41.45,140.033},{43.2833,141.4},{45.5167,141.95}},
{{53.15,141.833},{45.8833,142.083},{46.3667,143.617},{49.3833,143.25},{48.6333,144.75},{54.1333,143.017},{53.15,141.833}},
{{25.1167,121.283},{25.,122.},{21.9333,120.717},{23.6167,120.117},{25.1167,121.283}},
{{19.9833,109.567},{19.9667,110.95},{18.7833,110.533},{18.5,108.683},{19.9833,109.567}},
{{74.0333,-119.733},{73.4833,-115.317},{71.0833,-122.8},{71.9667,-126.},{74.3333,-124.783},{74.0333,-119.733}},
{{72.6,-114.6},{72.5167,-108.6},{71.6,-107.85},{73.35,-108.083},{72.3833,-105.2},{70.15,-100.967},{68.8,-102.9},{69.5,-106.583},{68.4667,-113.317},{70.,-117.433},{70.3333,-111.483},{70.6,-117.567},{71.5333,-115.067},{71.6833,-119.1},{72.9167,-117.35},{72.6,-114.6}},
{{51.6167,-55.6167},{49.55,-56.85},{49.0333,-55.3833},{49.2833,-53.4833},{47.5167,-53.6667},{48.1,-52.8333},{46.65,-53.0833},{47.9,-54.25},{46.8667,-55.3833},{47.95,-55.7667},{47.6167,-59.3},{47.9167,-59.4},{49.8333,-57.8333},{51.6167,-55.6167}},
{{68.2833,-67.2333},{66.6333,-61.2667},{64.8833,-63.55},{66.35,-64.35},{66.3,-68.5333},{65.5333,-67.3833},{62.9,-64.6333},{63.75,-69.},{61.8667,-66.0667},{63.05,-71.4},{64.45,-75.2},{64.4167,-78.},{65.4667,-77.4333},{64.7167,-75.3833},{65.45,-73.4833},{65.95,-71.25},{66.5667,-69.2167},{66.75,-72.9833},{68.7,-76.65},{70.6833,-79.0167},{69.7167,-80.95},{70.2333,-87.9167},{71.0833,-89.5667},{71.8833,-90.0167},{73.8667,-86.15},{70.9833,-86.8},{72.9,-85.6833},{73.7333,-81.9667},{71.8833,-80.9667},{72.75,-77.0667},{71.1833,-75.0833},{70.9833,-73.3833},{71.5667,-71.9167},{70.6333,-72.6167},{70.0167,-71.5333},{70.8833,-69.8667},{70.,-69.},{69.5333,-70.0333},{69.3333,-66.7667},{68.8667,-69.4},{68.2833,-67.2333}},
{{21.9167,-84.9167},{23.2167,-81.1333},{21.75,-77.3},{20.1833,-74.1333},{20.15,-77.4667},{22.6833,-81.8833},{21.9167,-84.9167}},
{{18.4333,-74.4833},{18.5333,-72.35},{19.75,-73.45},{19.7,-71.75},{18.6,-68.3167},{18.0333,-71.7667},{18.4333,-74.4833}},
{{71.7833,51.4},{73.3,53.7667},{73.1667,56.5667},{70.7333,57.6333},{71.7833,51.4}},
{{74.6833,56.9833},{73.3667,54.05},{76.95,68.5},{74.6833,56.9833}},
{{20.2667,-155.817},{19.5333,-154.8},{18.9167,-155.667},{20.2667,-155.817}}};

navIslands2={
{{-71.3769,-2.20365},{-70.2506,4.43698},{-70.4775,24.2961},{-69.6653,33.2767},{-70.0731,38.6591},{-68.5656,41.0469},{-65.8432,53.843},{-67.4503,59.1706},{-67.7729,69.8577},{-70.2663,68.0861},{-71.4422,71.4591},{-70.0811,72.8692},{-68.1508,79.3628},{-66.6926,88.1053},{-66.5987,97.7211},{-65.6542,100.036},{-66.9216,108.9},{-65.7003,113.201},{-66.9895,117.713},{-66.2697,126.148},{-67.0238,129.304},{-66.2121,134.138},{-66.3941,136.437},{-66.8497,146.459},{-67.8456,148.488},{-68.3396,153.821},{-71.3988,170.321},{-73.4744,169.014},{-74.9455,162.414},{-77.7929,164.423},{-79.2466,160.267},{-80.5482,160.775},{-82.2446,163.753},{-85.4947,-161.026},{-85.0676,-137.447},{-84.0049,-152.978},{-81.6405,-154.941},{-80.7045,-145.203},{-78.7694,-157.572},{-77.818,-149.372},{-76.3341,-149.439},{-74.4905,-135.531},{-73.8429,-113.95},{-75.1106,-100.403},{-73.5647,-102.285},{-72.5985,-89.1422},{-73.9365,-81.9814},{-73.8834,-76.9932},{-73.1817,-69.3351},{-69.4146,-68.865},{-67.4952,-66.525},{-63.2212,-57.3187},{-65.3235,-62.2053},{-67.492,-65.625},{-68.6502,-65.1813},{-71.1883,-60.9393},{-72.9236,-59.7882},{-74.3082,-61.6812},{-76.4334,-69.8797},{-78.0858,-69.0589},{-76.6449,-75.7566},{-77.1515,-83.2161},{-79.4514,-81.1462},{-80.696,-74.5005},{-80.1755,-60.0295},{-77.7098,-48.8684},{-78.5187,-44.8885},{-79.4476,-42.8768},{-80.5232,-45.8777},{-79.9793,-54.7916},{-81.6596,-72.0506},{-83.0018,-58.2884},{-80.4256,-30.6669},{-79.2814,-29.9607},{-78.6546,-36.5259},{-71.9846,-11.0888},{-71.3416,-3.58952},{-71.3769,-2.20365}},
{{-38.3333,144.633},{-38.8667,143.55},{-37.95,140.367},{-35.9167,139.483},{-34.15,138.083},{-35.3,136.833},{-32.5167,137.767},{-34.9833,135.95},{-32.2167,133.783},{-31.4833,131.2},{-32.3167,125.983},{-33.9333,120.017},{-35.15,117.95},{-34.3833,115.117},{-31.9,115.733},{-26.15,113.15},{-26.1333,114.233},{-24.1667,113.4},{-21.8167,114.033},{-20.5,116.817},{-19.5333,121.033},{-16.3667,122.933},{-17.8833,123.767},{-16.1333,123.617},{-15.5833,125.25},{-13.9,126.017},{-13.95,127.417},{-15.6,127.833},{-14.7667,128.483},{-15.3833,130.2},{-13.8833,129.7},{-12.1667,131.},{-12.1833,132.683},{-11.2,131.983},{-12.3,135.717},{-12.4,136.983},{-14.9833,135.45},{-17.7167,140.1},{-15.2333,141.717},{-11.0333,142.133},{-12.2,143.1},{-14.3833,143.783},{-14.9667,145.367},{-18.8833,146.283},{-20.25,148.783},{-22.55,149.633},{-22.5333,150.8},{-25.3,152.917},{-28.7833,153.617},{-35.7333,150.217},{-37.7167,149.617},{-39.15,146.367},{-38.3333,144.633}},
{{-43.1667,145.767},{-40.6833,144.7},{-40.9667,148.35},{-43.1833,147.983},{-43.1667,145.767}},
{{-41.6833,174.017},{-40.5,172.717},{-41.75,171.467},{-46.2167,166.733},{-45.8833,170.783},{-44.75,170.483},{-43.9,172.2},{-43.3,170.95},{-43.2667,172.75},{-41.6833,174.017}},
{{-39.6833,176.933},{-41.6167,175.233},{-40.2,175.35},{-39.4167,173.8},{-37.0667,174.95},{-34.4167,172.7},{-37.6333,176.},{-37.7,178.55},{-39.6833,176.933}},
{{-0.5,109.117},{-2.98333,110.233},{-3.56667,111.867},{-4.18333,114.633},{-3.55,116.},{-1.78333,116.217},{1.11667,117.9},{0.983333,119.017},{3.6,117.033},{4.16667,117.6},{5.35,119.283},{5.86667,117.467},{7.,117.15},{4.9,115.15},{4.58333,114.083},{2.68333,111.45},{1.35,111.383},{2.06667,109.65},{-0.5,109.117}},
{{5.56667,95.2333},{5.25,97.5167},{0.7,102.933},{0.25,102.433},{0.283333,103.733},{-1.03333,104.383},{-2.76667,104.533},{-3.23333,106.083},{-5.83333,105.783},{-5.93333,104.667},{-3.21667,101.6},{5.56667,95.2333}},
{{-7.83333,109.9},{-8.78333,114.567},{-7.8,114.433},{-6.43333,111.017},{-5.91667,107.033},{-6.76667,105.217},{-7.83333,109.9}},
{{-5.61667,119.583},{-3.1,118.767},{0.716667,120.033},{1.5,125.25},{0.366667,124.25},{0.35,120.25},{-1.4,120.667},{-0.766667,123.45},{-1.8,121.3},{-4.4,122.9},{-4.4,121.533},{-2.61667,120.767},{-4.38333,120.35},{-5.58333,120.067},{-5.61667,119.583}},
{{-7.88333,140.15},{-8.3,138.917},{-5.4,138.067},{-3.85,133.967},{-2.93333,133.867},{-4.08333,132.9},{-2.78333,131.95},{-2.1,133.933},{-1.43333,130.95},{-0.35,132.433},{-1.43333,134.233},{-3.36667,135.117},{-1.46667,137.85},{-2.6,141.},{-5.98333,147.483},{-7.46667,147.183},{-10.2333,150.883},{-10.1,147.717},{-7.5,144.517},{-8.23333,142.133},{-9.03333,143.333},{-9.13333,141.},{-7.88333,140.15}},
{{18.4,122.283},{15.2833,121.383},{13.9833,121.95},{13.7833,123.933},{12.55,124.083},{13.9667,122.533},{13.1667,122.6},{13.8,120.633},{16.3167,119.783},{18.5333,120.6},{18.4,122.283}},
{{9.8,125.45},{7.26667,126.617},{6.26667,126.2},{7.25,125.667},{5.58333,125.4},{7.81667,123.683},{7.1,121.883},{8.71667,123.4},{7.96667,123.683},{9.,125.517},{9.8,125.45}},
{{-54.5167,-72.0167},{-54.4667,-69.},{-52.7667,-70.4167},{-52.65,-68.6167},{-54.65,-65.1333},{-54.8833,-68.6333},{-54.5167,-72.0167}}};

ClosedLine[a_]:=Line[Append[a,First[a]]]

ort[x_]:=x/Sqrt[x[[1]]^2+x[[2]]^2+x[[3]]^2];

ort2[x_]:=x/Sqrt[x[[1]]^2+x[[2]]^2];

norma[x_]:=Sqrt[x[[1]]^2+x[[2]]^2+x[[3]]^2];

povprecje[list_]:=Apply[Plus,list]/Length[list];

(*program za subdivizijo vej na d delov, dani so cikli*)
EdgesOnFace[lice_]:=Module[{i},(*iz cikla dobimo veje*)
AppendTo[Table[{lice[[i]],lice[[i+1]]},{i,1,Length[lice]-1}]
,{Last[lice],First[lice]}]];

EdgesOnFaces[cic_]:=Block[{edgs={},n=Length[cic],ed,i},(*vse veje iz ciklov*)
		Do[ed=EdgesOnFace[cic[[i]]];edgs=Union[edgs,ed],
			{i,1,n}];
		edgs=Union[Map[Sort,edgs,1]]];

zemljaData01={navEurasia,navAfrica,navAmericas,navIslands1,navIslands2};

pretvorba[{psi_,fi_}]:={Cos[fi Pi/(180)]Cos[psi Pi/(180)],Sin[fi Pi/(180)]Cos[psi Pi/(180)],Sin[psi Pi/(180)]}//N;

zemljaData02=Map[pretvorba,zemljaData01,{3}];

kotzyosjo[v1_]:=Module[{v={v1[[1]],v1[[2]]}},If[v[[1]]≤0,ArcCos[ort[v][[2]]],2Pi-ArcCos[ort[v][[2]]]]//N];

euler[v_]:=Module[{v0=ort[v],vxy={v[[1]],v[[2]]},vxy0},
If[norma[vxy]<0.000001,{0.,0.},
vxy0=ort2[vxy];{If[vxy0[[1]]≤0,ArcCos[vxy0[[2]]],-ArcCos[vxy0[[2]]]],ArcCos[v0[[3]]]}//N]]

norma[{x_,y_}]:=Sqrt[x^2+y^2];
ort2[v_]:=v/norma[v];

ClosedLine[a_]:=Line[Append[a,First[a]]]

dodajprvega[li_]:=Join[li,{First[li]}];

zemljaData02=Map[pretvorba,zemljaData01,{3}];

(*zemljaData2=Map[pretvorba,zemljaData,{2}];*)

(*nekoliko drugace mejne tocke. Ce so ze na
mejni ploskvi*)

(*zemljaData01=Map[WorldData,World]
*)

(*zemljaData01N=DeleteCases[Map[Select[#,Last[#1]==First[#1]&]&,zemljaData01,{1}],{},{1}]*)

sredina[x_,y_]:=(x+y)/2;

vmesni[v1_,v2_]:=Module[{dx=v2[[1]]-v1[[1]],dy=v2[[2]]-v1[[2]],inc,j},inc=IntegerPart[(Abs[dx]+Abs[dy])2]+1;Table[N[v1+{dx/inc,dy/inc}j],{j,1,inc}]];

vmesni3D[v1_,v2_]:=Module[{dx=v2[[1]]-v1[[1]],dy=v2[[2]]-v1[[2]],dz=v2[[3]]-v1[[3]],inc,j},inc=IntegerPart[(Abs[dx]+Abs[dy]+Abs[dz])30]+1;Table[N[ort[v1+{dx/inc,dy/inc,dz/inc}j]],{j,1,inc}]];

vmesni3D[{0,0,0},{0.04,0.02,0.04}]

interpol[lis_]:=Module[{rezlist={},i}, rezlist=Append[rezlist,First[lis]];Do[rezlist=Append[rezlist,sredina[lis[[i]],lis[[i+1]]]];rezlist=Append[rezlist,lis[[i+1]]],{i,1,Length[lis]-1}];rezlist];

interpolvmesni[lis_]:=Module[{rezlist={First[lis]},i}, Do[rezlist=Join[rezlist,vmesni[lis[[i]],lis[[i+1]]]],{i,1,Length[lis]-1}];rezlist];

interpolvmesni3D[lis_]:=Module[{rezlist={First[lis]},i}, Do[rezlist=Join[rezlist,vmesni3D[lis[[i]],lis[[i+1]]]],{i,1,Length[lis]-1}];rezlist];

(*zemljaData01N2=Map[interpolvmesni,zemljaData01,{2}];*)

(*zemljaData02=Map[pretvorba,zemljaData01N2,{3}];*)

zemljaData02=Map[interpolvmesni3D,zemljaData02,{2}];

Length[zemljaData02]

dolocitevSProjekcijo[p1_][r_]:=Block[{c1,pove,f,dre,ris1,ris2,gra,stran1,stran,pove1,m,drevo,edg,ed1,i,ran,pot1,zatt,
		alledges,cikli,urej,urejen,veje,slika1,slika2,gra1,dre1,fun4,preplin,grpepo,tocka,normala,poli,sredineedges,vertort,maxi,edgefirst,sosedni,c1izb,v,e},
poli=p1;
		c1=poli[[1]];
f=Length[c1];v=Length[Union[Flatten[c1]]];e=f+v-2;
vertcoor2=	vertcoor1=poli[[2]];

vertort=Map[ort,vertcoor2];

port={p1[[1]],vertort};

alledges=Union[Map[Sort,EdgesOnFaces[c1],1]];



sredineedges=Map[ort,Map[povprecje,Map[vertort[[#]]&,alledges,1]]];
maxi=Max[Map[r.#&,sredineedges]]-0.0000001;

edgefirst=alledges[[First[Select[Range[e],sredineedges[[#]].r >maxi&]]]];


sosedni=Select[Range[f],Length[Intersection[c1[[#]],edgefirst]]==2&];
c1izb=First[sosedni];
poin=First[Complement[c1[[c1izb]],edgefirst]];

c1izb=If[Sign[Det[{vertort[[poin]],vertort[[edgefirst[[1]]]],vertort[[edgefirst[[2]]]]}]]==Sign[Det[{r,vertort[[edgefirst[[1]]]],vertort[[edgefirst[[2]]]]}]],sosedni[[1]],sosedni[[2]]];
edgefirst2=If[Det[{vertort[[poin]],vertort[[edgefirst[[1]]]],vertort[[edgefirst[[2]]]]}]>0,edgefirst,Reverse[edgefirst]];
normala=Cross[vertcoor2[[c1[[c1izb,2]]]]-vertcoor2[[c1[[c1izb,1]]]],vertcoor2[[c1[[c1izb,3]]]]-vertcoor2[[c1[[c1izb,1]]]]];

tocka=vertcoor2[[c1[[c1izb,1]]]];

(*r(normala.tocka)/(normala.r)*)


{r(normala.tocka)/(normala.r),{c1izb,edgefirst2}}

]

dolocitevSProjekcijoSplosna[p1_][r_]:=Block[{c1,pove,f,dre,ris1,ris2,gra,stran1,stran,pove1,m,drevo,edg,ed1,i,ran,pot1,zatt,
		alledges,cikli,urej,urejen,veje,slika1,slika2,gra1,dre1,fun4,preplin,grpepo,tocka,normala,poli,sredineedges,vertort,maxi,edgefirst,sosedni,c1izb,v,e,points,normals,indmin},
poli=p1;
		c1=poli[[1]];
f=Length[c1];v=Length[Union[Flatten[c1]]];e=f+v-2;
vertcoor2=	vertcoor1=poli[[2]];




normals=Table[ort[Cross[vertcoor2[[c1[[i,2]]]]-vertcoor2[[c1[[i,1]]]],vertcoor2[[c1[[i,3]]]]-vertcoor2[[c1[[i,1]]]]]],{i,1,f}];


points=Table[vertcoor2[[c1[[i,1]]]],{i,1,f}];
razdalje=Table[If[r.normals[[i]]>0.01,norma[r(normals[[i]].points[[i]])/(normals[[i]].r)],100],{i,1,f}];
minraz=Min[razdalje];(*Print["minraz",minraz];*)
indmin=First[Select[Range[f],razdalje[[#]]<minraz+0.0001&]];(*Print["indmin",indmin];*)
{r(normals[[indmin]].points[[indmin]])/(normals[[indmin]].r),{indmin,{1,1}}}

]

dolocitev3[p1_,net1_,ind_][poligon_]:=Module[{c1,pove,f,dre,ris1,ris2,gra,stran1,stran,pove1,m,drevo,edg,ed1,i,ran,pot1,zatt,
		alledges,cikli,urej,urejen,veje,slika1,slika2,gra1,dre1,fun4,preplin,grpepo,tocka,normala,poli,sredineedges,vertort,maxi,edgefirst,sosedni,c1izb,v,e,novpoli={},linije={},ii,novat,x,y,pol={}},
poli=p1;
		c1=poli[[1]];
f=Length[c1];v=Length[Union[Flatten[c1]]];e=f+v-2;
vertcoor1=poli[[2]];

poligondodan=poligon;
If[Length[Cases[poligon,{x_,{ind,y_}}]]<1,Return[{}]];
linije=If[(Length[Cases[poligon,{x_,{ind,y_}}]]==Length[poligon]),{poligon},


zacetek=First[Select[poligondodan,!(#[[2,1]]==ind)&]];pozic=First[First[Position[poligondodan,zacetek]]];poligondodan=RotateLeft[poligondodan,pozic-1];poligondodan=Append[poligondodan,zacetek];
linije={};
linija={};
Do[prvi=poligondodan[[ii]];drugi=poligondodan[[ii+1]];

Which[prvi[[2,1]]==ind && drugi[[2,1]]==ind,
linija=Append[linija,drugi],
prvi[[2,1]]==ind &&!( drugi[[2,1]]==ind),linije=Append[linije,linija];linija={}
,!(prvi[[2,1]]==ind)&& drugi[[2,1]]==ind,linija={drugi}


,True,Continue[]],{ii,1,Length[poligondodan]-1}];linije];




linije/.{{x1_Real,y1_Real,z1_Real}
,{w1_Integer,{q1_,q2_}}}->dolocitevLabirint[p1,net1,ind][{x1,y1,z1}]]

(*preslika dolocitev na svet*)

dolocitevLabirint[p1_,net1_,ind_][r_]:=Module[{c1=p1[[1]],vercoor1=p1[[2]],net=net1[[1]],r1,r1p,r2,r2p,r3,r3p,c0,c0p,v0,v0p,alpha,betha,v,vp},
r1=vercoor1[[c1[[ind,1]]]];
r1p=net[[ind,1]];
r2=vercoor1[[c1[[ind,2]]]];
r2p=net[[ind,2]];
r3=vercoor1[[c1[[ind,3]]]];
r3p=net[[ind,3]];
c0=ort[(r2-r1)];
c0p=ort2[(r2p-r1p)];
v=r3-r1-((r3-r1).c0)c0;
v0=ort[v];
vp=r3p-r1p-((r3p-r1p).c0p)c0p;
v0p=ort2[vp];
alpha=(r-r1).c0;
betha=(r-r1).v0;
r1p+alpha c0p+betha v0p

]

(*rotate[psi_,theta_,phi_][vec_]:=Rotate3D[vec,psi,theta,phi];*)

rotate[psi_,theta_,phi_][vec_]:={{Cos[phi] Cos[psi]-Cos[theta] Sin[phi] Sin[psi],Cos[psi] Sin[phi]+Cos[phi] Cos[theta] Sin[psi],Sin[psi] Sin[theta]},{-Cos[psi] Cos[theta] Sin[phi]-Cos[phi] Sin[psi],Cos[phi] Cos[psi] Cos[theta]-Sin[phi] Sin[psi],Cos[psi] Sin[theta]},{Sin[phi] Sin[theta],-Cos[phi] Sin[theta],Cos[theta]}}.vec;

drevesa1={{{1,2},{1,3},{1,4}},{{1,2},{1,4},{1,6},{2,3},{2,7},{4,5},{3,8}},{{1,2},{1,3},{1,4},{1,5},{2,6}},{{1,2},{1,5},{1,8},{2,3},{2,10},{5,4},{5,6},{8,7},{8,9},{3,12},{10,11},{4,14},{6,15},{7,16},{9,17},{12,13},{11,19},{15,18},{13,20}},{{1,2},{1,3},{1,4},{1,5},{1,7},{2,6},{2,9},{3,8},{4,10},{5,11},{6,12}},{{3,4},{4,5},{3,12},{4,14},{14,13},{12,11},{3,2},{11,10},{5,1},{1,23},{23,8},{8,24},{11,19},{19,17},{5,6},{10,9},{17,16},{8,7},{14,15},{19,20},{16,18},{2,21},{16,22}}};

telesa1={{{{1,2,3},{1,3,4},{1,4,2},{2,4,3}},{{0,0,1.7320508075688772935`2.},{1.6329931618554520655`2.,0,-0.5773502691896257645`2.},{-0.8164965809277260327`2.,1.4142135623730950488`2.,-0.5773502691896257645`2.},{-0.8164965809277260327`2.,-1.4142135623730950488`2.,-0.5773502691896257645`2.}}},{{{1,2,3},{1,3,4},{1,4,5},{1,5,2},{2,5,6},{2,6,3},{3,6,4},{4,6,5}},{{0,0,1.4142135623730950488`2.},{1.4142135623730950488`5.,0,0``24.5485},{0``29.2788,1.4142135623730950488`5.,0``24.5485},{-1.4142135623730950488`5.,0``28.9778,0``24.5485},{0``28.801700000000004,-1.4142135623730950488`5.,0``24.5485},{0``24.247400000000003,0``28.9778,-1.4142135623730950488`5.}}},{{{1,2,5,3},{1,3,7,4},{1,4,6,2},{2,6,8,5},{3,5,8,7},{4,7,8,6}},{{0,0,1.2247448713915890491`2.},{1.154700538379251529`2.,0,0.4082482904638630164`2.},{-0.5773502691896257645`2.,1.`2.,0.4082482904638630164`2.},{-0.5773502691896257645`2.,-1.`2.,0.4082482904638630164`2.},{0.5773502691896257645`2.,1.`2.,-0.4082482904638630164`2.},{0.5773502691896257645`2.,-1.`2.,-0.4082482904638630164`2.},{-1.154700538379251529`5.,0``32.01772876696043,-0.4082482904638630164`5.},{0``28.95487660777572,0``29.43178653840292,-1.2247448713915890491`5.}}},{{{1,2,3},{1,3,4},{1,4,5},{1,5,6},{1,6,2},{2,6,8},{2,8,7},{2,7,3},{3,7,9},{3,9,4},{4,9,10},{4,10,5},{5,10,11},{5,11,6},{6,11,8},{7,8,12},{7,12,9},{8,11,12},{9,12,10},{10,12,11}},{{0,0,1.1755705045849462583`2.},{1.051462224238267212`2.,0,0.525731112119133606`2.},{0.3249196962329063261`2.,1.`2.,0.525731112119133606`2.},{-0.8506508083520399322`2.,0.6180339887498948482`2.,0.525731112119133606`2.},{-0.8506508083520399322`2.,-0.6180339887498948482`2.,0.525731112119133606`2.},{0.3249196962329063261`2.,-1.`2.,0.525731112119133606`2.},{0.8506508083520399322`2.,0.6180339887498948482`2.,-0.525731112119133606`2.},{0.8506508083520399322`2.,-0.6180339887498948482`2.,-0.525731112119133606`2.},{-0.3249196962329063261`2.,1.`2.,-0.525731112119133606`2.},{-1.051462224238267212`5.,0``31.065051991234508,-0.525731112119133606`5.},{-0.3249196962329063261`2.,-1.`2.,-0.525731112119133606`2.},{0``28.374440627124027,0``28.770689346441216,-1.1755705045849462583`5.}}},{{{1,2,5,8,3},{1,3,7,10,4},{1,4,9,6,2},{2,6,12,11,5},{3,8,14,13,7},{4,10,16,15,9},{5,11,17,14,8},{6,9,15,18,12},{7,13,19,16,10},{11,12,18,20,17},{13,14,17,20,19},{15,16,19,20,18}},{{0,0,1.0704662693192697958`2.},{0.7136441795461798639`2.,0,0.7978784486061615971`2.},{-0.3568220897730899319`2.,0.6180339887498948482`2.,0.7978784486061615971`2.},{-0.3568220897730899319`2.,-0.6180339887498948482`2.,0.7978784486061615971`2.},{0.7978784486061615971`2.,0.6180339887498948482`2.,0.3568220897730899319`2.},{0.7978784486061615971`2.,-0.6180339887498948482`2.,0.3568220897730899319`2.},{-0.9341723589627156964`2.,0.3819660112501051518`2.,0.3568220897730899319`2.},{0.1362939103565540994`2.,1.`2.,0.3568220897730899319`2.},{0.1362939103565540994`2.,-1.`2.,0.3568220897730899319`2.},{-0.9341723589627156964`2.,-0.3819660112501051518`2.,0.3568220897730899319`2.},{0.9341723589627156964`2.,0.3819660112501051518`2.,-0.3568220897730899319`2.},{0.9341723589627156964`2.,-0.3819660112501051518`2.,-0.3568220897730899319`2.},{-0.7978784486061615971`2.,0.6180339887498948482`2.,-0.3568220897730899319`2.},{-0.1362939103565540994`2.,1.`2.,-0.3568220897730899319`2.},{-0.1362939103565540994`2.,-1.`2.,-0.3568220897730899319`2.},{-0.7978784486061615971`2.,-0.6180339887498948482`2.,-0.3568220897730899319`2.},{0.3568220897730899319`2.,0.6180339887498948482`2.,-0.7978784486061615971`2.},{0.3568220897730899319`2.,-0.6180339887498948482`2.,-0.7978784486061615971`2.},{-0.7136441795461798639`5.,0``29.484126156288326,-0.7978784486061615971`5.},{0``28.605023280445437,0``28.613501034449353,-1.0704662693192697958`5.}}}};

mrezeRotPlos[kk_,ii1_,indvert_,phi_,popo_,sirina_,dolzina_]:=Module[{p1,lica,drevo,mr,ime,ime2,died,ime3,gr0,gr1,imena1,k,vertcoor1,vertcoor2,v,center,ind,poligoni,polieder,vstop=0,kkk,net1,i,psi,theta,Data2,Data3,Data4,Data5,Data02,Data03,Data04,Data05},
		(*telo damo v centralno lego *)
p1=telesa1[[ii1]];
dre1=drevesa1[[ii1]];
vertcoor1=p1[[2]];c1=p1[[1]];f=Length[c1];v=Length[Union[Flatten[p1[[1]]]]];
	center=Apply[Plus,vertcoor1]/v;e=f+v-2;
vertcoor2=N[Map[#-center&,vertcoor1],6];
p1={c1,vertcoor2};
vertikala=povprecje[Map[p1[[2]][[#]]&,c1[[dre1[[1,1]]]]]];
{psi,theta}=euler[vertikala];
(*telo se zavrtimo*)
p1={p1[[1]],Map[rotate[phi,-theta,psi],p1[[2]]]};
(*telo se zavrtimo*)
pove=AdjacencyPairsHI[c1];	vertcoor1=p1[[2]];ni=Map[Length,c1];
c1=ChangeOrientation[dre1][c1];
net1=NetOfConvex[c1,dre1,vertcoor1][{0.12345675434543677991,0.13987654987654373453}//N];
gra1={GrayLevel[0.9],Map[Polygon,net1[[1]],{1}]};
gra2={RGBColor[1, 1, 0.501961],Map[Line,net1[[1]],{1}]};
p1={c1,p1[[2]]};
died=p1;poligoni=Map[dolocitevSProjekcijoSplosna[p1],zemljaData02,{3}];
poploskvah=Table[Table[{ii,Map[dolocitev3[p1,net1,ind],poligoni[[ii]],{1}]},{ii,1,Length[poligoni]}],{ind,1,Length[p1[[1]]]}];
plos=DeleteCases[DeleteCases[DeleteCases[poploskvah,{},{4}],{},{3}],{xxx_Integer},{2}];
poploskvi=Table[Table[{GrayLevel[0],Map[Line,plos[[ii,kkk,2]],{2}]},{kkk,1,Length[plos[[ii]]]}],{ii,1,Length[p1[[1]]]}];
Data01={Table[Table[{ii 900/60,n},{n,-10800/60,10800/60,240/60}],{ii,-6,6,1}],Table[Table[{n,ii 900/60},{n,-5400/60,5400/60,240/60}],{ii,0,24}]};
Data02=Map[interpolvmesni,Data01,{2}];
Data02=Map[pretvorba,Data02,{3}];
poligoni1=Map[dolocitevSProjekcijoSplosna[p1],Data02,{3}];
poploskvah1=Table[Table[{ii,Map[dolocitev3[p1,net1,ind],poligoni1[[ii]],{1}]},{ii,1,Length[poligoni1]}],{ind,1,Length[p1[[1]]]}];
plos1=DeleteCases[DeleteCases[DeleteCases[poploskvah1,{},{4}],{},{3}],{xxx_Integer},{2}];
poploskvi1=Table[Table[{Thickness[0.001],GrayLevel[0.8],Map[Line,plos1[[ii,kkk,2]],{2}]},{kkk,1,Length[plos1[[ii]]]}],{ii,1,Length[p1[[1]]]}];
{{gra1,gra2,poploskvi1,poploskvi}}
	]

Manipulate[With[{lab=Quiet[mrezeRotPlos[1,ind,1,k,1,7,13]]},Graphics[lab[[1]],ImageSize->{500,500}]],{{k,0,"rotate around north pole"},Range[0,3.2,0.1]},{{ind,1,""},{1->"Tetrahedron",2->"Octahedron",3->"Cube",4->"Icosahedron",5->"Dodecahedron"},ControlType->SetterBar},SynchronousInitialization->False,
AutorunSequencing->{1},
SynchronousUpdating->False,SaveDefinitions->True]

The Demonstration shows polyhedral maps of Earth. It needs 1-3 minutes to produce a map.

Contributed by: Izidor Hafner

Using coordinates from:
 Hans Milton
"Celestial Navigation"
 http://demonstrations.wolfram.com/CelestialNavigation/
 Wolfram Demonstrations Project