![]() |
Beschleunigung Polarkoordinaten <--> kartesische Koord
Hallo allerseits,
ich muss sehr sehr oft kartesische Koordinaten (Real, Imag) und Polarkoordinaten (Radius,theta(-pi..pi)) ineinander umwandeln. Und möchte das möglichst schnell machen. Bisher sieht das so aus wie unten aufgeschrieben. Wer kann das noch etwas schneller - am besten wohl in Assembler? Daran habe ich mich aber noch nicht getraut. Danke Steamengine TYPE Complex = record CASE Byte OF 1 : (R, I : double); 2 : (Rad, Theta : double); end; procedure RecToPol(var X : Complex); {rectangular to polar coordinates ]-pi..0..pi] } VAR r:double; BEGIN r:=sqrt(x.r*x.r + x.i*x.i); if r=0 then //no 0/0 in arctan2! begin x.i:=0; end else begin //arctan2(y,x) macht -pi..0..pi x.i:=arctan2(x.i,x.r); end; X.R:=r; END; procedure PolToRec(var X : Complex); {polar to rectangular coordinates } var sss,ccc:extended; BEGIN //Reihenfolge: erst den imag-Teil zuweisen, dann real-teil, //weil der bis zum letzten Schritt noch unveränert ist. SinCos(X.Theta,sss,ccc); X.I := X.Rad * sss; X.R := X.Rad * ccc; End; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:08 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz