summaryrefslogtreecommitdiff
path: root/valuesunit.pas
diff options
context:
space:
mode:
Diffstat (limited to 'valuesunit.pas')
-rw-r--r--valuesunit.pas48
1 files changed, 36 insertions, 12 deletions
diff --git a/valuesunit.pas b/valuesunit.pas
index 97d960f..a571955 100644
--- a/valuesunit.pas
+++ b/valuesunit.pas
@@ -20,10 +20,10 @@ type
constructor create;
destructor destroy; override;
procedure readFromFile(dat: string); overload;
- procedure readFromFile(ti: tExtPoint; dat: string); overload;
- procedure readFromFile(minT,maxT: extended; dat: string); overload;
+ procedure readFromFile(ti: tInt64Point; dat: string); overload;
+ procedure readFromFile(minT,maxT: int64; dat: string); overload;
function count: int64;
- function timeInterval: tExtPoint;
+ function timeInterval: tInt64Point;
procedure intersect(v: tValues);
end;
@@ -34,7 +34,7 @@ function timeToInt64(s: string): int64;
implementation
uses
- math, dateutils;
+ dateutils;
constructor tValues.create;
begin
@@ -50,15 +50,15 @@ end;
procedure tValues.readFromFile(dat: string);
begin
- readFromFile(-infinity,infinity,dat);
+ readFromFile(low(int64),high(int64),dat);
end;
-procedure tValues.readFromFile(ti: tExtPoint; dat: string);
+procedure tValues.readFromFile(ti: tInt64Point; dat: string);
begin
readFromFile(ti['x'],ti['y'],dat);
end;
-procedure tValues.readFromFile(minT,maxT: extended; dat: string);
+procedure tValues.readFromFile(minT,maxT: int64; dat: string);
var
f: textfile;
s: string;
@@ -169,15 +169,39 @@ begin
result:=length(werte);
end;
-function tValues.timeInterval: tExtPoint;
+function tValues.timeInterval: tInt64Point;
begin
- result['x']:=werte[0].time;
- result['y']:=werte[count-1].time;
+ if count=0 then begin
+ result['x']:=high(int64);
+ result['y']:=low(int64);
+ end
+ else begin
+ result['x']:=werte[0].time;
+ result['y']:=werte[count-1].time;
+ end;
end;
procedure tValues.intersect(v: tValues);
+var
+ i,t: int64;
begin
- if
+ if (count=0) or (v.count=0) or (timeInterval=v.timeInterval) then
+ exit;
+ t:=v.timeInterval['x'];
+ i:=0;
+ while (i<count) and (werte[i].time<t) do
+ inc(i);
+ if i>0 then begin
+ for t:=i to count-1 do
+ werte[t-i]:=werte[t];
+ setlength(werte,count-i);
+ end;
+
+ t:=v.timeInterval['y'];
+ while (count>0) and (werte[count-1].time>t) do
+ setlength(werte,length(werte)-1);
+
+ v.intersect(self);
end;
// general functions ***********************************************************
@@ -190,7 +214,7 @@ begin
round(w1.time*(1-x) + w2.time*x);
for c:='x' to 'z' do begin
result.vec[c]:=
- round(w1.vec[c]*(1-x) + w2.vec[c]*x);
+ w1.vec[c]*(1-x) + w2.vec[c]*x;
end;
end;