summaryrefslogtreecommitdiff
path: root/romunit.pas
diff options
context:
space:
mode:
Diffstat (limited to 'romunit.pas')
-rw-r--r--romunit.pas33
1 files changed, 23 insertions, 10 deletions
diff --git a/romunit.pas b/romunit.pas
index 28e0df5..bfd4ca9 100644
--- a/romunit.pas
+++ b/romunit.pas
@@ -1063,7 +1063,8 @@ procedure fenstern(var dat: tExtPointArray; breite: extended; alteMitte: boolean
var
i,j,len: longint;
extrema: tLongintArray;
- pp,mpp: extended;
+ pps: tExtendedArray;
+ mpp: extended;
begin
if not alteMitte then begin
setlength(extrema,0);
@@ -1077,19 +1078,31 @@ begin
inc(len);
end;
setlength(extrema,len);
- fensterMitte:=-1;
- mpp:=-1;
+ setlength(pps,len);
for i:=0 to length(extrema)-1 do begin
- pp:=-1;
+ pps[i]:=-1;
for j:=0 to length(extrema)-1 do
if (abs(dat[extrema[j]]['x']-dat[extrema[i]]['x'])<2) and
- (abs(dat[extrema[j]]['y']-dat[extrema[i]]['y'])>pp) then
- pp:=abs(dat[extrema[j]]['y']-dat[extrema[i]]['y']);
- if pp>mpp then begin
- mpp:=pp;
- fensterMitte:=extrema[i];
- end;
+ (abs(dat[extrema[j]]['y']-dat[extrema[i]]['y'])>pps[i]) then
+ pps[i]:=abs(dat[extrema[j]]['y']-dat[extrema[i]]['y']);
end;
+ mpp:=pps[0];
+ for i:=0 to length(pps)-1 do
+ if pps[i]>mpp then
+ mpp:=pps[i];
+ i:=0;
+ while (i<length(pps)) and
+ (pps[i]<mpp/2) do
+ inc(i);
+ j:=length(pps)-1;
+ while (j>=0) and
+ (pps[j]<mpp/2) do
+ dec(j);
+ mpp:=(dat[extrema[i]]['x']+dat[extrema[j]]['x'])/2;
+ fensterMitte:=0;
+ while (fensterMitte<length(dat)) and
+ (dat[fensterMitte]['x']<mpp) do
+ inc(fensterMitte);
end;
for i:=0 to length(dat)-1 do