![]() |
Mathe-Unit mit math. Konstanten ?
Hallo;
Ich bin auf der Suche nach einer Art Mathe-Unit für Delphi. Ich brauche nämlich in meinem Programm neben Pi und e auch i (den Imaginärteil komplexer Zahlen). Bislang habe ich mir Pi und e, wenn ich es gebracht habe, immer definiert, aber vllt. gibts ja auch ne Unit, die diese Sachen (und am besten noch vieles mehr :D ) schon hat. Oder ist es sogar in der Math-Unit von Delphi enthalten und ich habe es nur noch nicht gesehen? Danke! |
Re: Mathe-Unit mit math. Konstanten ?
Für das Rechnen mit komplexen Zahlen wird dir eine Konstante nicht reichen. Da müsstest du eine Klasse dafür erzeugen, wofür sich aber eher neuere Delphiversionen (ab D10, wg. Klassenoperatoren) eignen.
|
Re: Mathe-Unit mit math. Konstanten ?
Naja, ich will nicht mit imaginären Zahlen sondern "nur" mit komplexen Zahlen rechnen... aber ich glaube, da steh ich vor dem selben Problem, oder?
|
Re: Mathe-Unit mit math. Konstanten ?
Folgende Konstanten sind aus der Unit JclMath aus der
![]()
Delphi-Quellcode:
{ Mathematical constants }
const Bernstein: Float = 0.2801694990238691330364364912307; // Bernstein constant Cbrt2: Float = 1.2599210498948731647672106072782; // CubeRoot(2) Cbrt3: Float = 1.4422495703074083823216383107801; // CubeRoot(3) Cbrt10: Float = 2.1544346900318837217592935665194; // CubeRoot(10) Cbrt100: Float = 4.6415888336127788924100763509194; // CubeRoot(100) CbrtPi: Float = 1.4645918875615232630201425272638; // CubeRoot(PI) Catalan: Float = 0.9159655941772190150546035149324; // Catalan constant Pi: Float = 3.1415926535897932384626433832795; // PI PiOn2: Float = 1.5707963267948966192313216916398; // PI / 2 PiOn3: Float = 1.0471975511965977461542144610932; // PI / 3 PiOn4: Float = 0.78539816339744830961566084581988; // PI / 4 Sqrt2: Float = 1.4142135623730950488016887242097; // Sqrt(2) Sqrt3: Float = 1.7320508075688772935274463415059; // Sqrt(3) Sqrt5: Float = 2.2360679774997896964091736687313; // Sqrt(5) Sqrt10: Float = 3.1622776601683793319988935444327; // Sqrt(10) SqrtPi: Float = 1.7724538509055160272981674833411; // Sqrt(PI) Sqrt2Pi: Float = 2.506628274631000502415765284811; // Sqrt(2 * PI) TwoPi: Float = 6.283185307179586476925286766559; // 2 * PI ThreePi: Float = 9.4247779607693797153879301498385; // 3 * PI Ln2: Float = 0.69314718055994530941723212145818; // Ln(2) Ln10: Float = 2.3025850929940456840179914546844; // Ln(10) LnPi: Float = 1.1447298858494001741434273513531; // Ln(PI) Log2: Float = 0.30102999566398119521373889472449; // Log10(2) Log3: Float = 0.47712125471966243729502790325512; // Log10(3) LogPi: Float = 0.4971498726941338543512682882909; // Log10(PI) LogE: Float = 0.43429448190325182765112891891661; // Log10(E) E: Float = 2.7182818284590452353602874713527; // Natural constant hLn2Pi: Float = 0.91893853320467274178032973640562; // Ln(2*PI)/2 inv2Pi: Float = 0.159154943091895; // 0.5 / Pi TwoToPower63: Float = 9223372036854775808.0; // 2^63 GoldenMean: Float = 1.618033988749894848204586834365638; // GoldenMean EulerMascheroni: Float = 0.5772156649015328606065120900824; // Euler GAMMA const MaxAngle: Float = 9223372036854775808.0; // 2^63 Rad {$IFDEF MATH_EXTENDED_PRECISION} MaxTanH: Float = 5678.2617031470719747459655389854; // Ln(2^16384)/2 MaxFactorial = 1754; MaxFloatingPoint: Float = 1.189731495357231765085759326628E+4932; // 2^16384 MinFloatingPoint: Float = 3.3621031431120935062626778173218E-4932; // 2^(-16382) {$ENDIF MATH_EXTENDED_PRECISION} {$IFDEF MATH_DOUBLE_PRECISION} MaxTanH: Float = 354.89135644669199842162284618659; // Ln(2^1024)/2 MaxFactorial = 170; MaxFloatingPoint: Float = 1.797693134862315907729305190789E+308; // 2^1024 MinFloatingPoint: Float = 2.2250738585072013830902327173324E-308; // 2^(-1022) {$ENDIF MATH_DOUBLE_PRECISION} {$IFDEF MATH_SINGLE_PRECISION} MaxTanH: Float = 44.361419555836499802702855773323; // Ln(2^128)/2 MaxFactorial = 33; MaxFloatingPoint: Float = 3.4028236692093846346337460743177E+38; // 2^128 MinFloatingPoint: Float = 1.1754943508222875079687365372222E-38; // 2^(-126) {$ENDIF MATH_SINGLE_PRECISION} const PiExt = 3.1415926535897932384626433832795; RatioDegToRad : Extended = PiExt / 180.0; RatioRadToDeg : Extended = 180.0 / PiExt; RatioGradToRad : Extended = PiExt / 200.0; RatioRadToGrad : Extended = 200.0 / PiExt; RatioDegToGrad : Extended = 200.0 / 180.0; RatioGradToDeg : Extended = 180.0 / 200.0; |
Re: Mathe-Unit mit math. Konstanten ?
Zitat:
|
Re: Mathe-Unit mit math. Konstanten ?
Zitat:
Mit imaginären Zahlen könntest du noch teilweise "normal" rechnen, nämlich bei der Addition und Subtraktion - mit anderen Operationen verlässt du sowieso die imaginären Zahlen. Da dir das wohl nicht genügen wird, musst du die bekannten Formeln entweder direkt in den Quelltext einbetten oder du abstrahierst das eben durch eine neuere Delphiversion, die Records mit Methoden kennt. |
Re: Mathe-Unit mit math. Konstanten ?
Danke an euch alle :thumb:
@Khabarakh: Ja, mkinzler hatte da mal was von Imaginären Zahle vor dem Edit stehen... Ja das i nicht einfach ne Konstante ist ist mir klar, aber es hätt ja ne Methode geben können, die diese ganze Problematik aufgreift... Naja, danke für eure Mühen, ich werde dann man schauen, wie ich das Problem löse. |
Re: Mathe-Unit mit math. Konstanten ?
Zitat:
Dabei sind nicht nur die Grundrechenarten, sondern auch trigonometrische und logarithmische Funktionen vorhanden. Es bleiben keine Wünsche offen. |
Re: Mathe-Unit mit math. Konstanten ?
perfekt :thumb: :thumb: :thumb:
|
Re: Mathe-Unit mit math. Konstanten ?
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:38 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