Animations

Réponse d'un filtre numérique

filtre numérique

Animation flash


filtre-num.mp
verbatimtex
%&latex
\documentclass{article}
\usepackage{amsmath}
\usepackage[utf8]{inputenc} 
\usepackage{xcolor}
\usepackage[charter]{mathdesign}
\begin{document}
etex
 
input LATEX;
 
u:=1cm;
 
% Fonction de calcul du module du filtre
vardef trans(suffix pn,zn)(expr kp,kz,M) =
  save H;
  numeric H;
  H:=1;
  for i:=0 upto (kp-1):
    H:=H/abs(M-pn[i]);
  endfor;
  for i:=0 upto (kz-1):
    H:=H*abs(M-zn[i]);
  endfor;
  H
enddef;
 
% fonction calculant l'angle OM Ox entre 0 et 180
vardef anglezero(suffix  omega,zeros)(expr ordre) =
 for i:=0 upto (ordre-1) :
   omega[i]:=angle(zeros[i]);
   if omega[i]<0:
     omega[i]:=omega[i]+180;
   fi;
 endfor;
enddef;
 
 
% l'ordre des polynomes au numerateur et denominateur
ordrenum:=2;
ordreden:=2;
 
% les zeros des polynomes
pair mesp[],mesz[];
mesz[0]:=(0.86u,0.5u);
mesz[1]:=(-.42u,0.90u);
mesp0:=(-0.52u,0.26u);
mesp1:=(0.55u,0.58u);
 
% les angles relatifs au zeros des polynomes
numeric mesanglesp[],mesanglesz[];
anglezero(mesanglesp,mesp)(ordreden);
anglezero(mesanglesz,mesz)(ordrenum);
 
pair M, mf,Hf;
numeric H,supH,decal;
path Hcourbe, axef,axemodule;
 
% decalage du repere de la courbe et rapport pour l'echelle
decal:=3u;
rapproj:=40;
 
 
axef:=(decal,0)--(decal+180/rapproj*u+u,0);
axemodule:=(decal,0)--(decal,3u);
 
for j:=0  upto 360 :
  i:=j/2; % on ne parcourt que la moitie du cercle
  M:=(cosd(i)*u,sind(i)*u);
  mf:=(i/rapproj*u+decal,0);
  H:=trans(mesp,mesz)(ordreden,ordrenum,M);
  Hf:=(xpart mf,H*u);
  if i=0 :
    Hcourbe:=Hf;
  else:
    Hcourbe:=Hcourbe--Hf;
  fi;
  beginfig(j);
    draw fullcircle scaled 4u;
    drawarrow (-2.3u,0)--(2.3u,0);
    drawarrow (0,-2.3u)--(0,2.3u);
    drawarrow axef;
    drawarrow axemodule;
    draw Hcourbe withcolor red withpen pencircle scaled 2pt;
    draw (0,0)--2*M dashed evenly;
    draw mf--Hf dashed evenly;
    dotlabel.urt(btex $f_M$ etex,mf);
    for k:=0 upto ordrenum-1 :
      draw 2*M--2*mesz[k] dashed evenly withcolor blue;
    endfor;
    for k:=0 upto ordreden-1 :
      draw 2*M--2*mesp[k] dashed evenly withcolor green;
    endfor;
    for k:=0 upto (ordrenum-1) :
      dotlabel.urt(TEX("$Z_"& decimal(k) &"$"),2*mesz[k]);
      dotlabel.bot(TEX("$f_{Z_"& decimal(k)&"}$"),(decal+mesanglesz[k]/rapproj*u,0));
    endfor;
    for k:=0 upto (ordreden-1) :
      dotlabel.urt(TEX("$P_"& decimal(k) &"$"),2*mesp[k]);
      dotlabel.bot(TEX("$f_{P_"& decimal(k)&"}$"),(decal+mesanglesp[k]/rapproj*u,0));
    endfor;
    dotlabel.urt(btex $M$ etex,2*M);
    dotlabel.bot(btex $\dfrac{F_e}{2}$ etex, (180/rapproj*u+decal,0));
    numeric mesabs[];
    mesabs0:=abs(M-mesp0);
    mesabs1:=abs(M-mesp1);
    mesabs3:=abs(M-mesz0);
    mesabs4:=abs(M-mesz1);
 
    label.rt(TEX("$\left|H(f)\right|=\dfrac{\prod_{k=0}^n MZ_k}{\prod_{k=0}^d MP_k}=\dfrac{" 
	& decimal(mesabs3) & 
	"\times{}"& decimal(mesabs4) & "}{" & 
	decimal(mesabs0)&"\times{}" & 
	decimal(mesabs1)&"}=" & 
	decimal((mesabs3*mesabs4)/(mesabs0*mesabs1))&"$"),(-3u,4u));
 
    label.bot(btex $f$ etex, (decal+180/rapproj*u+u,0));
    label.lft(btex $\left|H(f)\right|$ etex,(decal,2.6u));
    label.llft(btex i etex,(0,2u));
    label.lrt(btex 1 etex,(2u,0));
  endfig;
endfor;  
 
end.