Subversion Repositories wimsdev

Rev

Rev 18513 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
18506 bpr 1
!set slib_header_hyptiling=\
18430 bpr 2
\\ -----------------------------------------------------------------------------------\
3
\\ Action du groupe de Moebius etendu sur le disque de Poincare\
4
\\ -----------------------------------------------------------------------------------\
5
\\ Homographie ou antihomographie selon que g[3] vaut 0 ou 1.\
6
mob(g,z)=if(g[3],z=conj(z));(g[1]*z+g[2])/(conj(g[2])*z+conj(g[1]));\
7
\\ Produit et inverse dans le groupe de Moebius etendu\
8
mobx(g)=[g[1],g[2];conj(g[2]),conj(g[1])];\
9
mob_mul(g1,g2)=my(m=mobx(g1)*mobx(if(g1[3],conj(g2),g2)));[m[1,1],m[1,2],g1[3]!=g2[3]];\
10
mob_inv(g)=if(g[3],[g[1],-conj(g[2]),1],[conj(g[1]),-g[2],0]);\
18513 bpr 11
\\ Homographie (et anti) qui envoie 0 sur a et 1 sur b, avec a \in D et b a l'horizon\
18502 bpr 12
mob_ori(a,b,c)=my(e=sqrt(b),g1=(e-conj(e)*a)/(1-norm(a)));[g1,a*conj(g1),c];\
18517 bpr 13
\\ Reflexion par rapport a la geodesique qui joint a et b\
18430 bpr 14
mob_ref(a,b)={\
15
  my(num=a*b*conj(a-b)+b-a,den=conj(a)*b-conj(b)*a,c,d,h);\
16
  d=if(norm(den)*1e8<norm(num),\
17
    if (norm(b)<norm(a),sqrt(a/conj(a)),sqrt(b/conj(b))),\
18
    c=num/den;(1+sqrt(1-norm(c)))/conj(c));\
18502 bpr 19
  h=mob_ori(a,d);\
18430 bpr 20
  mob_mul(h,mob_mul([1,0,1],mob_inv(h)))\
21
  };\
18513 bpr 22
lft_fwd(g,beta,l)=my(e=exp(I*beta/2));mob_mul(g,[e,e*l,0]);\
18430 bpr 23
\
18513 bpr 24
wims_export(pavage)={\
25
  my(res1,res2,res3,res4,[sommets,paves,aretes,daretes]=pavage,n=#paves[1]-1);\
26
  res1=matrix(#sommets,2,i,j,if(j==1,real(sommets[i]),imag(sommets[i])));\
27
  res2=matrix(#paves,n+2,i,j,if(j==1,n,if(j==n+2,paves[i][n+1][3],paves[i][j-1])));\
28
  [res1,res2]\
18430 bpr 29
};\
30
\
18513 bpr 31
hyp_pav(v,d,eps)={\
32
  my(n=#v,a,b,s,s1,s2,t,t1,t2,g,gg,cd0,cd1,cdd1,cd2,r2,f1,v1,w0,z,limit);\
18451 bpr 33
  if(eps>=1,limit=eps;eps=0,limit=1000);\
18430 bpr 34
  r2=(1-eps)^2;\
18449 bpr 35
  if(!v,return(0));\
18430 bpr 36
\\ Les reflexions qui engendrent W\
37
  g=vector(n,i,mob_ref(v[i],v[i%n+1]));\
38
\
18513 bpr 39
\\ Creation du premier pave et de son squelette\
18430 bpr 40
  \\ Pour chaque sommet, [arite restante, derniere arete cree, affixe, dans le disque?]\
41
  cd2=List(vector(n,s,[d[s]-2,if(s==1,n,s),v[s],norm(v[s])<r2]));\
42
  \\ Pour chaque arete, [origine, extremite, type, premier polygone borde, active]\
43
  cd1=List(vector(n,a,[a,a%n+1,a,1,cd2[a][4]||cd2[a%n+1][4]]));\
18513 bpr 44
  \\ Pour chaque arete duale [pave origine, pave extremite, arete croisee]\
45
  cdd1=List();\
46
  \\ Pour chaque pave, ses aretes et l'élément du groupe\
18430 bpr 47
  cd0=List([vector(n+1,a,if(a>n,[1,0,0],a))]);\
48
\
18449 bpr 49
  while(#cd0<limit&&f1<#cd1, f1+=1; v1=cd1[f1]; if(v1[5],\
18430 bpr 50
    s=v1[3]; \\ type de l'arete (ambigu)\
51
\\  Nouveau pave et ses aretes, manquantes ou pas\
52
    w0=vector(n+1);\
53
    w0[n+1]=gg=mob_mul(cd0[v1[4]][n+1],g[s]);\
18513 bpr 54
    w0[s]=a=f1; cd1[a][5]=0; listput(cdd1,[v1[4],#cd0+1,a]);\
18430 bpr 55
    s1=cd1[a][1]; s2=cd1[a][2];\
56
    b=cd0[v1[4]][s%n+1];\
57
    if(s2!=cd1[b][1]&&s2!=cd1[b][2],t=s1;s1=s2;s2=t); \\ arete mal orientee\
18457 bpr 58
    t1=(s-2)%n+1;\
59
    while(!cd2[s1][1]&&!w0[t1], \\ aretes precedent f1 qui sont deja la\
18513 bpr 60
      w0[t1]=a=cd2[s1][2]; cd1[a][5]=0; listput(cdd1,[cd1[a][4],#cd0+1,a]);\
18457 bpr 61
      s1=cd1[a][1]+cd1[a][2]-s1; t1=(t1-2)%n+1);\
62
    t2=s%n+1;\
63
    while(!cd2[s2][1]&&!w0[t2], \\ aretes suivant f1 qui sont deja la\
18513 bpr 64
      w0[t2]=a=cd2[s2][2]; cd1[a][5]=0; listput(cdd1,[cd1[a][4],#cd0+1,a]);\
18457 bpr 65
      s2=cd1[a][1]+cd1[a][2]-s2; t2=t2%n+1);\
66
    while(t1!=t2, \\ Il y a au moins deux aretes a creer\
67
      if(s1<s2,\
68
        z=mob(gg,v[t1]);\
69
        listput(cd2,[d[t1]-1,#cd1+1,z,norm(z)<r2]);\
70
        listput(cd1,[s1,#cd2,t1,#cd0+1,cd2[s1][4]||cd2[#cd2][4]]); w0[t1]=#cd1;\
71
        cd2[s1][1]-=1; cd2[s1][2]=#cd1; s1=#cd2; t1=(t1-2)%n+1,\
72
        z=mob(gg,v[t2%n+1]);\
73
        listput(cd2,[d[t2%n+1]-1,#cd1+1,z,norm(z)<r2]);\
74
        listput(cd1,[s2,#cd2,t2,#cd0+1,cd2[s2][4]||cd2[#cd2][4]]); w0[t2]=#cd1;\
75
        cd2[s2][1]-=1; cd2[s2][2]=#cd1; s2=#cd2; t2=t2%n+1));\
76
      listput(cd1,[s1,s2,t1,#cd0+1,cd2[s1][4]||cd2[s2][4]]); w0[t1]=#cd1;\
77
      cd2[s1][1]-=1; cd2[s1][2]=#cd1; cd2[s2][1]-=1; cd2[s2][2]=#cd1;\
78
      listput(cd0,w0)));\
18430 bpr 79
  for(f=1,#cd0,\
80
    w=cd0[f];a=cd1[w[1]];b=cd1[w[n]];\
81
    s=a[1];if(s!=b[1]&&s!=b[2],s=a[2]);\
82
    for(i=1,n,a=cd1[w[i]];w[i]=s;s=a[1]+a[2]-s);\
83
    cd0[f]=w);\
18513 bpr 84
  [vector(#cd2,i,cd2[i][3]),Vec(cd0),Vec(cd1),Vec(cdd1)]\
18430 bpr 85
};\
86
abc(A,B,C)={\
87
  if (A+B+C >= Pi, return(0));\
88
  my(cha=(cos(A)+cos(B)*cos(C))/(sin(B)*sin(C)),\
89
    chb=(cos(B)+cos(A)*cos(C))/(sin(A)*sin(C)),\
90
    chc=(cos(C)+cos(B)*cos(A))/(sin(B)*sin(A)));\
91
  [sqrt((cha-1)/(cha+1)),sqrt((chb-1)/(chb+1)),sqrt((chc-1)/(chc+1))]\
92
};\
18513 bpr 93
tangentiel(a,centre)={\
18502 bpr 94
  my(l,cs=apply(x->cos(x/2),a),\
95
    k=solve(t=0,1,vecsum(apply(x->asin(t*x),cs))-Pi),\
18513 bpr 96
    R=sqrt(2/(1+k)-1), g=[1,0,0], h, res=vector(#a));\
97
  if(centre,g=lft_fwd(lft_fwd([1,0,0],-asin(k*cs[1]),R),Pi/2,0));\
18502 bpr 98
  for(i=1,#a,\
99
    l=abc(Pi/2,a[i]/2,asin(k*cs[i]))[3];\
100
    g=lft_fwd(g,0,l);\
101
    res[i]=mob(g,0);\
102
    g=lft_fwd(g,Pi-a[i],l));\
18513 bpr 103
  [res,R]\
18502 bpr 104
};\
105
\
18513 bpr 106
catalan(d,limite,centre)={\
107
  my([h,R]=tangentiel(apply(x->2*Pi/x,d),centre));\
108
  [hyp_pav(h,d,limite),R,if(centre,0,R*I)]\
18517 bpr 109
}\