game_Racer
11-08-2011, 21:49
Сначала было так:
//критерий Михайлова
function mihailov(l:TStringList):boolean;
var
i,j,p,n,kv:byte;
w,u,v,up,vp,tan,tang:extended;
begin
image1.Canvas.MoveTo(0,trunc(image1.Height/2));
image1.Canvas.LineTo(image1.width,trunc(image1.Height/2));
image1.Canvas.MoveTo(trunc(image1.width/2),0);
image1.Canvas.LineTo(trunc(image1.width/2),image1.Height);
image1.Canvas.MoveTo(trunc(strtofloat(l[l.count-1])*10+image1.width/2),trunc(image1.Height/2));
n:=0;
kv:=0;
u:=0;
v:=0;
w:=0;
repeat
w:=w+0.01;
up:=u;
vp:=v;
j:=0;
u:=0;
v:=0;
if (v<>vp)and(up<>u) then tan:=tang;
for i:=1 to l.count do begin
j:=j+1;
p:=l.count-i;
case j of
1:u:=u+strtofloat(l[p])*(Exp((i-1)*Ln(w)));
2:v:=v+strtofloat(l[p])*(Exp((i-1)*Ln(w)));
3:u:=u+strtofloat(l[p])*(-Exp((i-1)*Ln(w)));
4:begin v:=v+strtofloat(l[p])*(-Exp((i-1)*Ln(w))); j:=0; end;
end;
end;
//Определяем, переходы по квадрантам
case kv of
0:if ((u>0)and(v>0)) then begin kv:=1; n:=n+1; end;
1:if not ((u>0)and(v>0)) then if (u<=0)and(v>0) then begin kv:=2; n:=n+1; end;
2:if not ((u<0)and(v>0)) then if (u<0)and(v<=0) then begin kv:=3; n:=n+1; end;
3:if not ((u<0)and(v<0)) then if (u>=0)and(v<0) then begin kv:=4; n:=n+1; end;
4:if not ((u>0)and(v<0)) then if (u>0)and(v>=0) then begin kv:=1; n:=n+1; end;
end;
image1.Canvas.LineTo(trunc(u*0.1+image1.width/2),trunc(v*(-0.1)+image1.Height/2));
if (v<>vp)and(up<>u) then
tang:=trunc(arctan((v-vp)/(u-up))*10000)/10000;
until (tan=tang)and(tan<>0);
if n=l.Count-1 then mihailov:=true else mihailov:=false;
end;
Потом я решил убрать рисование графика и сделал так:
//критерий Михайлова
function mihailov(l:TStringList):boolean;
var
i,j,p,n,kv:byte;
w,u,v,up,vp,tan,tang:extended;
begin
n:=0;
kv:=0;
u:=0;
v:=0;
w:=0;
repeat
w:=w+0.01;
up:=u;
vp:=v;
j:=0;
u:=0;
v:=0;
if (v<>vp)and(up<>u) then tan:=tang;
for i:=1 to l.count do begin
j:=j+1;
p:=l.count-i;
case j of
1:u:=u+strtofloat(l[p])*(Exp((i-1)*Ln(w)));
2:v:=v+strtofloat(l[p])*(Exp((i-1)*Ln(w)));
3:u:=u+strtofloat(l[p])*(-Exp((i-1)*Ln(w)));
4:begin v:=v+strtofloat(l[p])*(-Exp((i-1)*Ln(w))); j:=0; end;
end;
end;
//Определяем, переходы по квадрантам
case kv of
0:if ((u>0)and(v>0)) then begin kv:=1; n:=n+1; end;
1:if not ((u>0)and(v>0)) then if (u<=0)and(v>0) then begin kv:=2; n:=n+1; end;
2:if not ((u<0)and(v>0)) then if (u<0)and(v<=0) then begin kv:=3; n:=n+1; end;
3:if not ((u<0)and(v<0)) then if (u>=0)and(v<0) then begin kv:=4; n:=n+1; end;
4:if not ((u>0)and(v<0)) then if (u>0)and(v>=0) then begin kv:=1; n:=n+1; end;
end;
if (v<>vp)and(up<>u) then
tang:=trunc(arctan((v-vp)/(u-up))*10000)/10000;
until (tan=tang)and(tan<>0);
if n=l.Count-1 then mihailov:=true else mihailov:=false;
end;
Как только я убрал строку image1.Canvas.LineTo(trunc(u*0.1+image1.width/2),trunc(v*(-0.1)+image1.Height/2)); стал ругаться на until (tan=tang)and(tan<>0);
Я всего лишь студент, код наверное не красивый, по этому заранее извиняюсь.
//критерий Михайлова
function mihailov(l:TStringList):boolean;
var
i,j,p,n,kv:byte;
w,u,v,up,vp,tan,tang:extended;
begin
image1.Canvas.MoveTo(0,trunc(image1.Height/2));
image1.Canvas.LineTo(image1.width,trunc(image1.Height/2));
image1.Canvas.MoveTo(trunc(image1.width/2),0);
image1.Canvas.LineTo(trunc(image1.width/2),image1.Height);
image1.Canvas.MoveTo(trunc(strtofloat(l[l.count-1])*10+image1.width/2),trunc(image1.Height/2));
n:=0;
kv:=0;
u:=0;
v:=0;
w:=0;
repeat
w:=w+0.01;
up:=u;
vp:=v;
j:=0;
u:=0;
v:=0;
if (v<>vp)and(up<>u) then tan:=tang;
for i:=1 to l.count do begin
j:=j+1;
p:=l.count-i;
case j of
1:u:=u+strtofloat(l[p])*(Exp((i-1)*Ln(w)));
2:v:=v+strtofloat(l[p])*(Exp((i-1)*Ln(w)));
3:u:=u+strtofloat(l[p])*(-Exp((i-1)*Ln(w)));
4:begin v:=v+strtofloat(l[p])*(-Exp((i-1)*Ln(w))); j:=0; end;
end;
end;
//Определяем, переходы по квадрантам
case kv of
0:if ((u>0)and(v>0)) then begin kv:=1; n:=n+1; end;
1:if not ((u>0)and(v>0)) then if (u<=0)and(v>0) then begin kv:=2; n:=n+1; end;
2:if not ((u<0)and(v>0)) then if (u<0)and(v<=0) then begin kv:=3; n:=n+1; end;
3:if not ((u<0)and(v<0)) then if (u>=0)and(v<0) then begin kv:=4; n:=n+1; end;
4:if not ((u>0)and(v<0)) then if (u>0)and(v>=0) then begin kv:=1; n:=n+1; end;
end;
image1.Canvas.LineTo(trunc(u*0.1+image1.width/2),trunc(v*(-0.1)+image1.Height/2));
if (v<>vp)and(up<>u) then
tang:=trunc(arctan((v-vp)/(u-up))*10000)/10000;
until (tan=tang)and(tan<>0);
if n=l.Count-1 then mihailov:=true else mihailov:=false;
end;
Потом я решил убрать рисование графика и сделал так:
//критерий Михайлова
function mihailov(l:TStringList):boolean;
var
i,j,p,n,kv:byte;
w,u,v,up,vp,tan,tang:extended;
begin
n:=0;
kv:=0;
u:=0;
v:=0;
w:=0;
repeat
w:=w+0.01;
up:=u;
vp:=v;
j:=0;
u:=0;
v:=0;
if (v<>vp)and(up<>u) then tan:=tang;
for i:=1 to l.count do begin
j:=j+1;
p:=l.count-i;
case j of
1:u:=u+strtofloat(l[p])*(Exp((i-1)*Ln(w)));
2:v:=v+strtofloat(l[p])*(Exp((i-1)*Ln(w)));
3:u:=u+strtofloat(l[p])*(-Exp((i-1)*Ln(w)));
4:begin v:=v+strtofloat(l[p])*(-Exp((i-1)*Ln(w))); j:=0; end;
end;
end;
//Определяем, переходы по квадрантам
case kv of
0:if ((u>0)and(v>0)) then begin kv:=1; n:=n+1; end;
1:if not ((u>0)and(v>0)) then if (u<=0)and(v>0) then begin kv:=2; n:=n+1; end;
2:if not ((u<0)and(v>0)) then if (u<0)and(v<=0) then begin kv:=3; n:=n+1; end;
3:if not ((u<0)and(v<0)) then if (u>=0)and(v<0) then begin kv:=4; n:=n+1; end;
4:if not ((u>0)and(v<0)) then if (u>0)and(v>=0) then begin kv:=1; n:=n+1; end;
end;
if (v<>vp)and(up<>u) then
tang:=trunc(arctan((v-vp)/(u-up))*10000)/10000;
until (tan=tang)and(tan<>0);
if n=l.Count-1 then mihailov:=true else mihailov:=false;
end;
Как только я убрал строку image1.Canvas.LineTo(trunc(u*0.1+image1.width/2),trunc(v*(-0.1)+image1.Height/2)); стал ругаться на until (tan=tang)and(tan<>0);
Я всего лишь студент, код наверное не красивый, по этому заранее извиняюсь.