09.05.2013 Views

Algoritmos Heurísticos de Cobertura de Arcos

Algoritmos Heurísticos de Cobertura de Arcos

Algoritmos Heurísticos de Cobertura de Arcos

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Procedure CalculaCustoConversao(N1,N2,N3:Integer ; Var Penal:Integer);<br />

var V1L,V1C,V2L,V2C,SenoTeta,CosTeta,A: Real;<br />

PenalFrente,PenalDireita,PenalEsquerda:Integer;<br />

begin<br />

PenalFrente:=StrToInt(Form1.Edit13.Text);<br />

PenalDireita:=StrToInt(Form1.Edit14.Text);<br />

PenalEsquerda:=StrToInt(Form1.Edit15.Text);<br />

V1L:= No<strong>de</strong>[N2].Linha-No<strong>de</strong>[N1].Linha;<br />

V1C:= No<strong>de</strong>[N2].Coluna-No<strong>de</strong>[N1].Coluna;<br />

V2L:= No<strong>de</strong>[N3].Linha-No<strong>de</strong>[N2].Linha;<br />

V2C:= No<strong>de</strong>[N3].Coluna-No<strong>de</strong>[N2].Coluna;<br />

A:=Sqrt((V1L*V1L+V1C*V1C)*(V2L*V2L+V2C*V2C));<br />

SenoTeta:= (V1L*V2C-V1C*V2L)/A;<br />

CosTeta:= (V1L*V2L+V1C*V2C)/A;<br />

If CosTeta>0.866 then penal:=PenalFrente; // Em frente (Angulo -30 a 30)<br />

If SenoTeta>=0.5 then penal:=PenalEsquerda; // Para Esquerda (Angulo 30 a 150)<br />

If CosTeta0 Then<br />

begin<br />

//WriteLn(Re<strong>de</strong>,N1,' ',N2,' ',N3,' 0');<br />

WriteLn(Re<strong>de</strong>,N1,' ',N2,' ',N3,' ',Penal);<br />

Linha :='';<br />

Linha := Linha + IntToStr(N1) + ' ';<br />

Linha := Linha + IntToStr(N2) + ' ';<br />

Linha := Linha + IntToStr(N3) + ' ';<br />

Linha := Linha + IntToStr(Penal) + ' ';<br />

ListBox1.Items.Add (Linha);<br />

end;<br />

L:=Link[L].ProxSuc;<br />

end;<br />

K:=Link[K].ProxSuc;<br />

end;<br />

End;<br />

CloseFile(Re<strong>de</strong>);<br />

end;<br />

146

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!