ALS Invité
|
Posté le: 26 Mar 2005 9:58 Sujet du message: Re: polygone de newton d'un polynome |
|
|
Bonjour,
On pourra utiliser la procédure enveloppe_convexe_inferieure qui représente l'enveloppe convexe inférieure d'une liste de points L.
J'ai écrit également enveloppe_convexe_superieure qui représente l'enveloppe convexe supérieure d'une liste de points L, mais elle ne vous sera pas utile.
Ces 2 procédures sont testées sur une liste E := [a, b, c, d, e, f, g, h, i, j, k] de 11 points.
Code: |
> with(geometry):
> point(a,[6,0]):point(b,[5,2]):point(c,[0,3]):point(d,[-4,2]):point(e,[-2,1]):point(f,[-5,-3]):
> point(g,[-2,-4]):point(h,[-1,-1]):point(i,[1,-7]):point(j,[2,-2]):point(k,[5,-3]):
> E:=[a,b,c,d,e,f,g,h,i,j,k];
E := [a, b, c, d, e, f, g, h, i, j, k]
> enveloppe_convexe_inferieure:=proc(L)
> local ch,ec,k,i,index_min,index_max,x_min,x_max,ECI;
> ch:=map(coordinates,convexhull(L));
> index_min:=1: index_max:=1: x_min:=ch[1][1]: x_max:=ch[1][1]:
> for k to nops(ch) do
> if ch[k][1]<x_min then x_min:=ch[k][1]: index_min:=k end if:
> if ch[k][1]>x_max then x_max:=ch[k][1]: index_max:=k end if:
> end do:
> ECI:=NULL:
> for k from index_min to index_min+nops(ch)-1 do
> if k>nops(ch) then i:=k-nops(ch) else i:=k end if;
> ECI:=ECI,ch[i]:
> if i=index_max then break end if;
> end do;
> ECI:=[ECI];
> plot(ECI,color=blue);
> end proc:
>
> enveloppe_convexe_inferieure(E);
> enveloppe_convexe_superieure:=proc(L)
> local ch,ec,k,i,index_min,index_max,x_min,x_max,ECS;
> ch:=map(coordinates,convexhull(L));
> index_min:=1: index_max:=1: x_min:=ch[1][1]: x_max:=ch[1][1]:
> for k to nops(ch) do
> if ch[k][1]<x_min then x_min:=ch[k][1]: index_min:=k end if:
> if ch[k][1]>x_max then x_max:=ch[k][1]: index_max:=k end if:
> end do:
> ECS:=NULL:
> for k from index_max to index_max+nops(ch)-1 do
> if k>nops(ch) then i:=k-nops(ch) else i:=k end if;
> ECS:=ECS,ch[i]:
> if i=index_min then break end if;
> end do;
> ECS:=[ECS];
> plot(ECS,color=green);
> end proc:
>
> enveloppe_convexe_superieure(E);
> with(plots):
> F:=map(coordinates,E): F:=[op(F),F[1]]: plot(F);
> display({enveloppe_convexe_inferieure(E),enveloppe_convexe_superieure(E)});
|
|
|