summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-10-24 15:50:26 +0200
committerErich Eckner <git@eckner.net>2019-10-24 15:50:26 +0200
commit513a1805cb8dbc883ee3bc245d1107162b68ca63 (patch)
treed764499c137ffe43a8a8f26ffb708bf6a102167c
parentc2c627a9aeae59fe067db2439f5aa939fed77f64 (diff)
downloadepost-513a1805cb8dbc883ee3bc245d1107162b68ca63.tar.xz
typenunit.pas: tRTTransformation aufgespalten
-rw-r--r--typenunit.pas117
1 files changed, 101 insertions, 16 deletions
diff --git a/typenunit.pas b/typenunit.pas
index c68d4f1..cfbbdf4 100644
--- a/typenunit.pas
+++ b/typenunit.pas
@@ -447,8 +447,19 @@ type
function positionAufAchseZuWert(const l: tLage; x: extended; auszerhalbIstFehler: boolean = true): extended; override;
function dumpParams: string; override;
end;
- tRTTransformation = class (tKoordinatenTransformation)
- // repräsentiert die Transformation der Koordinaten bei einer Radontransformation
+ tRTVorbereitungsTransformation = class (tKoordinatenTransformation)
+ // repräsentiert die Transformation der Koordinaten zu Beginn einer Radontransformation
+ constructor create; overload;
+ constructor create(vorg: tTransformation);
+ procedure aktualisiereAchsen; override;
+ procedure aktualisiereXsTs; override;
+ // keine Änderung der Positionen, der Werte(skalierung)
+ function wertZuPositionAufAchse(const l: tLage; x: extended; auszerhalbIstFehler: boolean = true): extended; override;
+ function positionAufAchseZuWert(const l: tLage; x: extended; auszerhalbIstFehler: boolean = true): extended; override;
+ function dumpParams: string; override;
+ end;
+ tRTLineOutTransformation = class (tKoordinatenTransformation)
+ // repräsentiert die Transformation der Koordinaten beim Lineout einer Radontransformation
winkelSchritte: int64;
constructor create; overload;
constructor create(vorg: tTransformation; ws: int64);
@@ -2437,6 +2448,10 @@ begin
if vertikal then begin
outAchsen['y','x']:=0;
outAchsen['y','y']:=(inXSTS['y']-1)/(inAchsen['y','y']-inAchsen['y','x']);
+ if zentrieren then begin
+ outAchsen['y','x']:=-outAchsen['y','y']/2;
+ outAchsen['y','y']:=outAchsen['y','y']+outAchsen['y','x'];
+ end;
end
else
for c:='x' to 'y' do
@@ -2495,36 +2510,106 @@ begin
result:=result + ' ' + inherited dumpParams;
end;
-// tRTTransformation ***********************************************************
+// tRTVorbereitungsTransformation **********************************************
+
+constructor tRTVorbereitungsTransformation.create;
+begin
+ inherited create;
+end;
-constructor tRTTransformation.create;
+constructor tRTVorbereitungsTransformation.create(vorg: tTransformation);
+begin
+ inherited create;
+ fuegeVorgaengerHinzu(vorg);
+end;
+
+procedure tRTVorbereitungsTransformation.aktualisiereAchsen;
+var
+ c: char;
+begin
+ for c:='x' to 'y' do begin
+ outAchsen[c,'x']:=inAchsen[c,'x']; // TODO: vllt. zentrieren?
+ outAchsen[c,'y']:=outAchsen[c,'x'] + (inAchsen[c,'y'] - inAchsen[c,'x']) * outXSTS['x']/inXSTS['x'];
+ end;
+end;
+
+procedure tRTVorbereitungsTransformation.aktualisiereXsTs;
+begin
+ outXSTS['x']:=3*max(inXSTS['x'],inXSTS['y']); // TODO: wieso gerade so?
+ outXSTS['y']:=outXSTS['x'];
+ aktualisiereAchsen;
+end;
+
+function tRTVorbereitungsTransformation.wertZuPositionAufAchse(const l: tLage; x: extended; auszerhalbIstFehler: boolean = true): extended;
+var
+ c: char;
+begin
+ if auszerhalbIstFehler then
+ testeAuszerhalb(false,false,l,x);
+ // egal, wie die Werte vor der RTV aussahen, wir setzen sie danach linear
+ c:=paralleleRichtung[l];
+ if x=outAchsen[c,'x'] then
+ result:=0
+ else
+ result:=(x-outAchsen[c,'x'])/(outAchsen[c,'y']-outAchsen[c,'x']);
+ result:=result*(1-1/outXSTS[c]);
+ if auszerhalbIstFehler then
+ testeAuszerhalb(false,true,l,result);
+end;
+
+function tRTVorbereitungsTransformation.positionAufAchseZuWert(const l: tLage; x: extended; auszerhalbIstFehler: boolean = true): extended;
+var
+ c: char;
+begin
+ if auszerhalbIstFehler then
+ testeAuszerhalb(false,true,l,x);
+ // egal, wie die Werte vor der RTV aussahen, wir setzen sie danach linear
+ c:=paralleleRichtung[l];
+ if x=0 then
+ result:=outAchsen[c,'x']
+ else
+ result:=x/(1-1/outXSTS[c])*(outAchsen[c,'y']-outAchsen[c,'x'])+outAchsen[c,'x'];
+ if auszerhalbIstFehler then
+ testeAuszerhalb(false,false,l,result);
+end;
+
+function tRTVorbereitungsTransformation.dumpParams: string;
+begin
+ result:='RTvb ' + inherited dumpParams;
+end;
+
+// tRTLineOutTransformation ****************************************************
+
+constructor tRTLineOutTransformation.create;
begin
inherited create;
winkelSchritte:=180;
end;
-constructor tRTTransformation.create(vorg: tTransformation; ws: int64);
+constructor tRTLineOutTransformation.create(vorg: tTransformation; ws: int64);
begin
inherited create;
winkelSchritte:=ws;
fuegeVorgaengerHinzu(vorg);
end;
-procedure tRTTransformation.aktualisiereAchsen;
+procedure tRTLineOutTransformation.aktualisiereAchsen;
begin
- outAchsen['x','y']:=pi*(1-1/winkelSchritte)/2; // Winkel-Stopp
- outAchsen['x','x']:=-outAchsen['x','y']; // Winkel-Start
- outAchsen['y','y']:=sqrt(sqr(inAchsen['x','y']-inAchsen['x','x']) + sqr(inAchsen['y','y']-inAchsen['y','x']))/2; // Verschiebe-Stopp
- outAchsen['y','x']:=-outAchsen['y','y']; // Verschiebe-Start
+ outAchsen['x','y']:=pi*(1-1/winkelSchritte)/2; // Winkel von pi/2
+ outAchsen['x','x']:=-outAchsen['x','y']; // bis -pi/2
+ // Vorsicht, Willkür! (Ergebnis müsste aber für x gleich sein)
+ outAchsen['y','y']:=(inAchsen['y','y']-inAchsen['y','x'])*outXSTS['y']/inXSTS['y']/2; // dY bleibt erhalten
+ outAchsen['y','x']:=-outAchsen['y','y'];
end;
-procedure tRTTransformation.aktualisiereXsTs;
+procedure tRTLineOutTransformation.aktualisiereXsTs;
begin
outXSTS['x']:=winkelSchritte;
- outXSTS['y']:=round(2*sqrt(inXSTS*inXSTS));
+ outXSTS['y']:=round(sqrt(inXSTS*inXSTS)/2);
+ aktualisiereAchsen;
end;
-function tRTTransformation.wertZuPositionAufAchse(const l: tLage; x: extended; auszerhalbIstFehler: boolean = true): extended;
+function tRTLineOutTransformation.wertZuPositionAufAchse(const l: tLage; x: extended; auszerhalbIstFehler: boolean = true): extended;
var
c: char;
begin
@@ -2541,7 +2626,7 @@ begin
testeAuszerhalb(false,true,l,result);
end;
-function tRTTransformation.positionAufAchseZuWert(const l: tLage; x: extended; auszerhalbIstFehler: boolean = true): extended;
+function tRTLineOutTransformation.positionAufAchseZuWert(const l: tLage; x: extended; auszerhalbIstFehler: boolean = true): extended;
var
c: char;
begin
@@ -2557,9 +2642,9 @@ begin
testeAuszerhalb(false,false,l,result);
end;
-function tRTTransformation.dumpParams: string;
+function tRTLineOutTransformation.dumpParams: string;
begin
- result:='RT: '+intToStr(winkelSchritte);
+ result:='RTlo: '+intToStr(winkelSchritte);
result:=result + ' ' + inherited dumpParams;
end;