archive-com.com » COM » E » EFG2.COM

Total: 878

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • efg's Graphics -- Transparent Button
    over an image Place the TBevel and TLabel on top of the TImage If the TBevels or TLabels are already on the form you can cut and paste them back onto the form to change the z order to be on top of the TImage Otherwise consider using the BringToFront method The TLabel object still receives OnMouse events but the TBevel object doesn t receive any events In fact the TBevel absorbs the mouse events unless Bevel Enabled is set to FALSE in the FormCreate method Position the TLabel inside the TBevel and set the Font Alignment and AutoSize properties as desired You ll probably want to set the Transparent property of the TLabel to TRUE The OnMouse Events from the TImage are inspected for activity over the TBevel objects including OnMouseDown for clicks and OnMouseMove fo r hover button behavior To simplify determining whether the X Y mouse event over the TImage correspond to one of the TBevels a rectangle based on the image coordinates Bevel1RectInImageCoordinates below is computed in the FormCreate VAR BasePoint TPoint Do this once to improve efficiency of PtInRect calculations BasePoint Image ScreenToClient ClientToScreen Point Bevel1 Left Bevel1 Top Bevel1RectInImageCoordinates Rect BasePoint X BasePoint Y BasePoint X Bevel1 Width BasePoint Y Bevel1 Height Then in the ImageMouseDown and ImageMouseMove methods an IF statement determines if the mouse event corresponds to a specific TBevel IF WinProcs PtInRect Bevel1RectInImageCoordinates Point X Y THEN The ImageMouseMove was used to create a hover button effect while the ImageMouseDown was used as a Bevel OnClick The FocusControl keyboard shortcut of the TLabels cannot be used but the TForm s OnKeyDown can be used to trigger Alt Key keyboard shortcuts This is an extension of an idea shown in How to Program Delphi 3 by Frank Engo pp 290 291 In

    Original URL path: http://www.efg2.com/Lab/Graphics/TransparentButton.htm (2016-02-14)
    Open archived version from archive


  • efg's Mathematics Projects -- Complex Numbers
    format is appropriate for a given algorithm The Case statement in the Record definition allows either x y rectangular coordinates or r q polar coordinates to be stored in the same data structure TComplex data type TYPE TReal DOUBLE TComplexForm cfPolar cfRectangular TComplex RECORD CASE form TComplexForm OF cfRectangular x y TReal z x i y cfPolar r theta TReal z r CIS theta END where CIS theta COS theta i SIN theta theta PI PI in canonical form The assignment of a TComplex variable is usually via a CSet function CSet function FUNCTION CSet CONST a b TReal CONST f TComplexForm TComplex BEGIN RESULT form f CASE f OF cfRectangular BEGIN RESULT x a RESULT y b END cfPolar BEGIN RESULT r a RESULT theta b END END END CSet The function prototype for CSet defines a default TComplexForm of cfRectangular The array a of complex values used in many of the ComplexMathVerification project routines was defined as follows Definition of complex array VAR a ARRAY 1 21 OF TComplex a 1 CSet 0 0 0 0 a 3 CSet 0 5 0 5 a 4 CSet 0 5 0 5 a 5 CSet 0 5 0 5 a 6 CSet 1 0 0 0 a 7 CSet 1 0 1 0 a 8 CSet 0 0 1 0 a 9 CSet 1 0 1 0 a 12 CSet 0 0 1 0 a 13 CSet 1 0 1 0 a 16 CSet 0 0 3 0 a 17 CSet 5 0 3 0 a 19 CSet 5 0 3 0 a 20 CSet 0 0 3 0 a 21 CSet 5 0 3 0 Polar definitions a 2 CSet SQRT 0 5 PI 4 cfPolar 0 5 0 5i a 10 CSet 1 0 PI cfPolar 1 0i a 11 CSet SQRT 2 5 PI 4 cfPolar 1 i a 14 CSet 5 0 0 0 cfPolar 5 0i a 15 CSet SQRT 34 ArcTan 3 5 cfPolar 5 3i a 18 CSet 5 0 PI cfPolar 5 0i Such complex values can be displayed in either rectangular or polar form using the CToRectStr and CToPolarStr functions explained below Code to display array of complex values using CToRectStr and CToPolarStr Memo Lines Add Complex number definition and conversion CSet CtoRectStr CtoPolarStr Memo Lines Add Memo Lines Add rectangular polar Memo Lines Add FOR k Low a TO High a DO BEGIN Memo Lines Add Format 2d s s k CToRectStr a k 13 9 CToPolarStr a k 13 9 END The code above results in the follow TMemo data Array of TComplex values Complex number definition and conversion CSet CtoRectStr CtoPolarStr rectangular polar 1 0 000000000 0 000000000i 0 000000000 CIS 0 000000000 2 0 500000000 0 500000000i 0 707106781 CIS 0 785398163 3 0 500000000 0 500000000i 0 707106781 CIS 2 356194490 4 0 500000000 0 500000000i 0 707106781 CIS 2 356194490 5 0 500000000 0 500000000i 0 707106781 CIS 0 785398163 6 1 000000000 0 000000000i

    Original URL path: http://www.efg2.com/Lab/Mathematics/Complex/Numbers.htm (2016-02-14)
    Open archived version from archive

  • efg's Mathematics Projects -- Complex Arithmetic
    examples PROCEDURE TFormComplexMath ComplexArithmetic1 VAR u TComplex v TComplex z TComplex begin Memo Lines Add Complex arithmetic CAdd CSub CMult CDiv Memo Lines Add u CSet SQRT 2 PI 4 cfPolar Memo Lines Add Let u CToRectStr u 13 9 CToPolarStr u 13 9 v CSet SQRT 3 1 Memo Lines Add v CToRectStr v 13 9 CToPolarStr v 13 9 Memo Lines Add z CAdd u v Memo Lines Add u v CToRectStr z 13 9 CToPolarStr z 13 9 z CSub u v Memo Lines Add u v CToRectStr z 13 9 CToPolarStr z 13 9 z CMult u v Memo Lines Add u v CToRectStr z 13 9 CToPolarStr z 13 9 z CDiv u v Memo Lines Add u v CToRectStr z 13 9 CToPolarStr z 13 9 Memo Lines Add END Arithmetic1 CConjugate Complex conjugate The above expression for division using rectangular coordinates suggests introducing the concept of a complex conjugate The complex conjugate of v c id is given the symbol or v where c id Interestingly the conjugate of a complex number in polar form can also be formed by only negating the angular coordinate That is if z r q then z r q This result can be derived form the expression and the identities CConjugate function z a FUNCTION CConjugate CONST a TComplex TComplex BEGIN RESULT form a form CASE a form OF cfPolar BEGIN RESULT r a r RESULT theta FixAngle a theta END cfRectangular BEGIN RESULT x a x RESULT y a y END END END CConjugate CConjugate function results Complex conjugate z z z rectangular 0 0 0 0i 0 000000000 0 000000000i 0 5 0 5i 0 500000000 0 500000000i 0 5 0 5i 0 500000000 0 500000000i 0 5 0 5i 0 500000000 0 500000000i 0 5 0 5i 0 500000000 0 500000000i 1 0 0 0i 1 000000000 0 000000000i 1 0 1 0i 1 000000000 1 000000000i 0 0 1 0i 0 000000000 1 000000000i 1 0 1 0i 1 000000000 1 000000000i 1 0 0 0i 1 000000000 0 000000000i 1 0 1 0i 1 000000000 1 000000000i 0 0 1 0i 0 000000000 1 000000000i 1 0 1 0i 1 000000000 1 000000000i 5 0 0 0i 5 000000000 0 000000000i 5 0 3 0i 5 000000000 3 000000000i 0 0 3 0i 0 000000000 3 000000000i 5 0 3 0i 5 000000000 3 000000000i 5 0 0 0i 5 000000000 0 000000000i 5 0 3 0i 5 000000000 3 000000000i 0 0 3 0i 0 000000000 3 000000000i 5 0 3 0i 5 000000000 3 000000000i The product of a complex value and its conjugate is always a real number e g This value is the square of the distance from the origin to v The square root of this value is known as the norm magnitude modulus or absolute value of a complex value That is This means the complex quotient above with CDiv could be written as This form

    Original URL path: http://www.efg2.com/Lab/Mathematics/Complex/Arithmetic.htm (2016-02-14)
    Open archived version from archive

  • efg's Mathematics Projects -- Complex Logs and Powers
    n aTemp theta END END CIntPower Examples Complex integer powers using DeMoivre s theorem CIntPower z n z 3 z 3 z rectangular polar 1 0 0 0 0i 0 0000000 0 0000000i 0 0000000 CIS 0 0000000 2 0 5 0 5i 0 2500000 0 2500000i 0 3535534 CIS 2 3561945 3 0 5 0 5i 0 2500000 0 2500000i 0 3535534 CIS 0 7853982 4 0 5 0 5i 0 2500000 0 2500000i 0 3535534 CIS 0 7853982 5 0 5 0 5i 0 2500000 0 2500000i 0 3535534 CIS 2 3561945 6 1 0 0 0i 1 0000000 0 0000000i 1 0000000 CIS 0 0000000 7 1 0 1 0i 2 0000000 2 0000000i 2 8284271 CIS 2 3561945 8 0 0 1 0i 0 0000000 1 0000000i 1 0000000 CIS 1 5707963 9 1 0 1 0i 2 0000000 2 0000000i 2 8284271 CIS 0 7853982 10 1 0 0 0i 1 0000000 0 0000000i 1 0000000 CIS 3 1415927 11 1 0 1 0i 2 0000000 2 0000000i 2 8284271 CIS 0 7853982 12 0 0 1 0i 0 0000000 1 0000000i 1 0000000 CIS 1 5707963 13 1 0 1 0i 2 0000000 2 0000000i 2 8284271 CIS 2 3561945 14 5 0 0 0i 125 0000000 0 0000000i 125 0000000 CIS 0 0000000 15 5 0 3 0i 10 0000000 198 0000000i 198 2523644 CIS 1 6212585 16 0 0 3 0i 0 0000000 27 0000000i 27 0000000 CIS 1 5707963 17 5 0 3 0i 10 0000000 198 0000000i 198 2523644 CIS 1 5203342 18 5 0 0 0i 125 0000000 0 0000000i 125 0000000 CIS 3 1415927 19 5 0 3 0i 10 0000000 198 0000000i 198 2523644 CIS 1 5203342 20 0 0 3 0i 0 0000000 27 0000000i 27 0000000 CIS 1 5707963 21 5 0 3 0i 10 0000000 198 0000000i 198 2523644 CIS 1 5203342 CRealPower Complex value to real exponent While normally integers are used with DeMoivre s theorem real values work quite nicely also The computation of r x can be made using the math library function Power CRealPower function z a x FUNCTION CRealPower CONST a TComplex CONST x TReal TComplex VAR aTemp TComplex BEGIN IF CAbsSqr a 0 0 THEN IF Defuzz x 0 0 THEN RAISE EComplexZeroToZero Create RealPower ELSE RESULT ComplexZero 0 n 0 except for 0 0 ELSE BEGIN aTemp CConvert a cfPolar RESULT form cfPolar RESULT r Power aTemp r x RESULT theta FixAngle x aTemp theta END END CRealPower Examples Complex real powers using DeMoivre s theorem CRealPower z x z 1 5 z 1 5 z rectangular polar 1 0 0 0 0i 0 0000000 0 0000000i 0 0000000 CIS 0 0000000 2 0 5 0 5i 0 2275449 0 5493421i 0 5946036 CIS 1 1780972 3 0 5 0 5i 0 5493421 0 2275449i 0 5946036 CIS 2 7488936 4 0 5 0 5i 0 5493421 0 2275449i 0 5946036 CIS 2 7488936 5 0 5

    Original URL path: http://www.efg2.com/Lab/Mathematics/Complex/LogsAndPowers.htm (2016-02-14)
    Open archived version from archive

  • efg's Mathematics Projects -- Complex Trig Functions
    5i 0 403896455 0 564083141i 0 403896455 0 564083141i 6 1 0 0 0i 1 557407725 0 000000000i 1 557407725 0 000000000i 7 1 0 1 0i 0 271752585 1 083923327i 0 271752585 1 083923327i 8 0 0 1 0i 0 000000000 0 761594156i 0 000000000 0 761594156i 9 1 0 1 0i 0 271752585 1 083923327i 0 271752585 1 083923327i 10 1 0 0 0i 1 557407725 0 000000000i 1 557407725 0 000000000i 11 1 0 1 0i 0 271752585 1 083923327i 0 271752585 1 083923327i 12 0 0 1 0i 0 000000000 0 761594156i 0 000000000 0 761594156i 13 1 0 1 0i 0 271752585 1 083923327i 0 271752585 1 083923327i 14 5 0 0 0i 3 380515006 0 000000000i 3 380515006 0 000000000i 15 5 0 3 0i 0 002708236 1 004164711i 0 002708236 1 004164711i 16 0 0 3 0i 0 000000000 0 995054754i 0 000000000 0 995054754i 17 5 0 3 0i 0 002708236 1 004164711i 0 002708236 1 004164711i 18 5 0 0 0i 3 380515006 0 000000000i 3 380515006 0 000000000i 19 5 0 3 0i 0 002708236 1 004164711i 0 002708236 1 004164711i 20 0 0 3 0i 0 000000000 0 995054754i 0 000000000 0 995054754i 21 5 0 3 0i 0 002708236 1 004164711i 0 002708236 1 004164711i CSec Complex secant CSec function z sec a FUNCTION CSec CONST a TComplex TComplex VAR temp TComplex BEGIN Abramowitz formula 4 3 5 on p 72 temp CCos a TRY RESULT CDiv ComplexOne temp EXCEPT ON EComplexZeroDivide DO x 0 RESULT CSet Infinity Infinity ON EComplexInvalidOp DO 0 0 RESULT CSet Infinity Infinity END END CSec The table below in addition to showing the complex secant function also shows the results of the mathematical identity sec 2 z tan 2 z 1 This identity is just another version of the more recognized identity cos 2 z sin 2 z 1 Dividing all the terms in this identity by cos 2 z and rearranging the terms results in the identity used below Examples Complex secant CSec Sec z SEC z SEC 2 z TAN 2 z 1 z rectangular rectangular 1 0 0 0 0i 1 000000000 0 000000000i 1 000000000 0 000000000i 2 0 5 0 5i 0 949978868 0 239827631i 1 000000000 0 000000000i 3 0 5 0 5i 0 949978868 0 239827631i 1 000000000 0 000000000i 4 0 5 0 5i 0 949978868 0 239827631i 1 000000000 0 000000000i 5 0 5 0 5i 0 949978868 0 239827631i 1 000000000 0 000000000i 6 1 0 0 0i 1 850815718 0 000000000i 1 000000000 0 000000000i 7 1 0 1 0i 0 498337031 0 591083842i 1 000000000 0 000000000i 8 0 0 1 0i 0 648054274 0 000000000i 1 000000000 0 000000000i 9 1 0 1 0i 0 498337031 0 591083842i 1 000000000 0 000000000i 10 1 0 0 0i 1 850815718 0 000000000i 1 000000000 0 000000000i 11 1 0 1 0i 0 498337031 0 591083842i 1 000000000 0 000000000i 12

    Original URL path: http://www.efg2.com/Lab/Mathematics/Complex/Trig.htm (2016-02-14)
    Open archived version from archive

  • efg's Mathematics Projects -- Complex Hyperbolic Functions
    564083141 0 403896455i 5 0 5 0 5i 0 564083141 0 403896455i 0 564083141 0 403896455i 6 1 0 0 0i 0 761594156 0 000000000i 0 761594156 0 000000000i 7 1 0 1 0i 1 083923327 0 271752585i 1 083923327 0 271752585i 8 0 0 1 0i 0 000000000 1 557407725i 0 000000000 1 557407725i 9 1 0 1 0i 1 083923327 0 271752585i 1 083923327 0 271752585i 10 1 0 0 0i 0 761594156 0 000000000i 0 761594156 0 000000000i 11 1 0 1 0i 1 083923327 0 271752585i 1 083923327 0 271752585i 12 0 0 1 0i 0 000000000 1 557407725i 0 000000000 1 557407725i 13 1 0 1 0i 1 083923327 0 271752585i 1 083923327 0 271752585i 14 5 0 0 0i 0 999909204 0 000000000i 0 999909204 0 000000000i 15 5 0 3 0i 0 999912820 0 000025369i 0 999912820 0 000025369i 16 0 0 3 0i 0 000000000 0 142546543i 0 000000000 0 142546543i 17 5 0 3 0i 0 999912820 0 000025369i 0 999912820 0 000025369i 18 5 0 0 0i 0 999909204 0 000000000i 0 999909204 0 000000000i 19 5 0 3 0i 0 999912820 0 000025369i 0 999912820 0 000025369i 20 0 0 3 0i 0 000000000 0 142546543i 0 000000000 0 142546543i 21 5 0 3 0i 0 999912820 0 000025369i 0 999912820 0 000025369i CSech Complex hyperbolic secant CSech function z sech a FUNCTION CSech CONST a TComplex TComplex VAR aTemp TComplex BEGIN Abramowitz formula 4 5 5 on p 83 aTemp CCosh a TRY RESULT CDiv ComplexOne aTemp EXCEPT ON EComplexZeroDivide DO RESULT CSet PositiveInfinity PositiveInfinity ON EComplexInvalidOp DO RESULT CSet PositiveInfinity PositiveInfinity END END CSech The table below in addition to showing the complex secant function also shows the results of the mathematical identity tanh2 z sech2 z 1 This identity is just another version of the more recognized identity cosh2 z sinh2 z 1 Dividing all the terms in this identity by cosh2 z and rearranging the terms results in the identity used below Examples Complex hyperbolic secant CSech Sech z SECH z TANH 2 z SECH 2 z 1 z rectangular rectangular 1 0 0 0 0i 1 000000000 0 000000000i 1 000000000 0 000000000i 2 0 5 0 5i 0 949978868 0 239827631i 1 000000000 0 000000000i 3 0 5 0 5i 0 949978868 0 239827631i 1 000000000 0 000000000i 4 0 5 0 5i 0 949978868 0 239827631i 1 000000000 0 000000000i 5 0 5 0 5i 0 949978868 0 239827631i 1 000000000 0 000000000i 6 1 0 0 0i 0 648054274 0 000000000i 1 000000000 0 000000000i 7 1 0 1 0i 0 498337031 0 591083842i 1 000000000 0 000000000i 8 0 0 1 0i 1 850815718 0 000000000i 1 000000000 0 000000000i 9 1 0 1 0i 0 498337031 0 591083842i 1 000000000 0 000000000i 10 1 0 0 0i 0 648054274 0 000000000i 1 000000000 0 000000000i 11 1 0 1 0i 0 498337031 0 591083842i 1 000000000 0 000000000i 12

    Original URL path: http://www.efg2.com/Lab/Mathematics/Complex/Hyperbolic.htm (2016-02-14)
    Open archived version from archive

  • efg's Mathematics Projects -- Complex Bessel Functions
    Polar rectangular Memo Lines Add FOR k Low b TO High b DO BEGIN z CJ0 b k Memo Lines Add Format 2d s s k CToPolarStr b k 9 4 CToRectStr z 16 10 END Here are the test results Sample computed values of CJ0 Complex Bessel function CJ0 J0 z J0 z z Polar rectangular 1 0 0000 CIS 0 0000 1 0000000000 0 0000000000i 2 0 5000 CIS 0 0000 0 9384698072 0 0000000000i 3 10 0000 CIS 0 0000 0 2459357645 0 0000000000i 4 0 5000 CIS 0 5236 0 9682684872 0 0532808827i 5 10 0000 CIS 0 5236 5 0471892329 18 1437389326i 6 0 5000 CIS 0 7854 0 9990234640 0 0624932184i 7 10 0000 CIS 0 7854 138 8404659416 56 3704585539i 8 0 5000 CIS 1 3090 1 0546148557 0 0321025326i 9 10 0000 CIS 1 3090 1546 3765101169 1270 8491488690i 10 0 5000 CIS 1 5708 1 0634833707 0 0000000000i 11 10 0000 CIS 1 5708 2815 7166284663 0 0000000000i The above results match values in the Table of the Bessel Functions J 0 z and J 1 z for Complex Arguments The z values above were defined in polar coordinates to be consistent with the table of values CI0 Complex Hyperbolic Bessel function I 0 The terms in the CI0 series are the same as the CJ0 series but they are all additive instead of the alternating signs with the CJ0 function so CI0 is somewhat simpler than CJ0 CI0 function z I0 a FUNCTION CI0 CONST a TComplex TComplex CONST MaxTerm BYTE 35 EpsilonSqr TReal 1 0E 20 VAR aTemp TComplex i BYTE SizeSqr TReal term TComplex zSQR25 TComplex BEGIN aTemp CConvert a cfRectangular RESULT ComplexOne term 0 zSQR25 Cmult aTemp aTemp zSQR25 x 0 25 zSQR25 x zSQR25 y 0

    Original URL path: http://www.efg2.com/Lab/Mathematics/Complex/Bessel.htm (2016-02-14)
    Open archived version from archive

  • efg's Mathematics Projects -- Complex Gamma Function
    powers ARRAY 1 8 OF TComplex temp1 TComplex temp2 TComplex BEGIN aTemp CConvert a cfRectangular temp1 CLn aTemp ln z temp2 CSet aTemp x 0 5 aTemp y cfRectangular a 0 5 RESULT CMult temp1 temp2 a 0 5 ln a RESULT CSub RESULT aTemp a 0 5 ln a a RESULT x RESULT x HalfLn2PI temp1 ComplexOne powers 1 CDiv temp1 aTemp a 1 temp2 CMult powers 1 powers 1 a 2 FOR i 2 TO 8 DO powers i CMult powers i 1 temp2 FOR i 8 DOWNTO 1 DO add in reverse order BEGIN temp1 CSet c i powers i x c i powers i y cfRectangular RESULT CAdd RESULT temp1 END END CAsymptoticLnGamma FUNCTION CLnGamma CONST a TComplex TComplex VAR aTemp TComplex lna TComplex temp TComplex BEGIN aTemp CConvert a cfRectangular IF aTemp x 0 0 AND DeFuzz aTemp y 0 0 THEN BEGIN IF DeFuzz Abs Frac aTemp x 0 0 negative integer THEN BEGIN RESULT CSet PositiveInfinity PositiveInfinity EXIT END END IF aTemp y 0 0 3rd or 4th quadrant THEN BEGIN temp CConjugate aTemp RESULT CLnGamma temp try again in 1st or 2nd quadrant RESULT CConjugate RESULT left this out 1 3 91 END ELSE BEGIN IF aTemp x 9 0 left of NBS table range THEN BEGIN lna CLn aTemp temp CSet aTemp x 1 0 aTemp y cfRectangular temp CLnGamma temp recursive call RESULT CSub temp lna END ELSE RESULT CAsymptoticLnGamma aTemp NBS range 9 Re z 10 END END CLnGamma Selected computed values that match published values Complex LnGamma function CLnGamma Ln Gamma z Ln Gamma z z rectangular 0 0 1 0i 0 650923199302 1 872436647262i 0 0 1 0i 0 650923199302 1 872436647262i 0 0 3 0i 4 342756588258 0 517445555726i 0 0 3 0i 4 342756588258 0 517445555726i 0 5 0 5i 0 112387242810 0 750729202121i 1 0 0 0i 0 000000000000 0 000000000000i 1 0 1 0i 0 650923199302 0 301640320468i 1 0 1 0i 0 650923199302 0 301640320468i 5 0 0 0i 3 178053830348 0 000000000000i 5 0 3 0i 2 244246717020 4 714089538905i Note CGamma Complex Gamma function The CGamma function involves both the CLnGamma from above and CExp functions CGamma function FUNCTION CGamma CONST a TComplex TComplex VAR lna TComplex BEGIN lna CLnGamma a IF lna x 75 0 arbitrary cutoff for infinity THEN RESULT CSet PositiveInfinity PositiveInfinity ELSE IF lna x 200 0 arbitrary cutoff for underflow THEN RESULT ComplexZero avoid underflow ELSE RESULT CExp lna END CGamma This code calls the CGamma function for various complex values a k Memo Lines Add Complex Gamma function CGamma Gamma z Memo Lines Add Memo Lines Add Gamma z Gamma z Memo Lines Add z rectangular polar Memo Lines Add FOR k Low a TO High a DO BEGIN z CGamma a k Memo Lines Add Format 2d s s s k CToRectStr a k 5 1 CToRectStr z 13 8 CToPolarStr z 13 8 END The code above puts its result in a

    Original URL path: http://www.efg2.com/Lab/Mathematics/Complex/Gamma.htm (2016-02-14)
    Open archived version from archive