home *** CD-ROM | disk | FTP | other *** search
/ MacPeople 2001 June 15 / MACPEOPLE-2001-06-15.ISO.7z / MACPEOPLE-2001-06-15.ISO / オンラインウエア / 新着!オンラインウエア16 / KHyX.sit / KHyX / Modules / HMComplexNumbers / stack.txt < prev   
Text File  |  2001-03-08  |  7KB  |  224 lines

  1. -- stack: in
  2. -- format: 10 (HyperCard 2)
  3. -- flags: 0x1000 (none)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=112, y1=113, x2=528, y2=353)
  7. -- screen: Rect(x1=0, y1=0, x2=640, y2=480)
  8. -- card dimensions: w=416 h=240
  9. -- scroll: x=0 y=0
  10. -- background count: 1
  11. -- first background id: 2754
  12. -- card count: 1
  13. -- first card id: 3602
  14. -- list block id: 2156
  15. -- print block id: 0
  16. -- font table block id: 3385
  17. -- style table block id: 3183
  18. -- free block count: 5
  19. -- free size: 5728 bytes
  20. -- total size: 16384 bytes
  21. -- stack block size: 6656 bytes
  22. -- created by hypercard version: 0x02418000
  23. -- compacted by hypercard version: 0x02418000
  24. -- modified by hypercard version: 0x02418000
  25. -- opened by hypercard version: 0x02418000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x8000000008000000
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0x8888222288882222
  30. -- patterns[4]: 0x88AA22AA88AA22AA
  31. -- patterns[5]: 0xCCAA33AACCAA33AA
  32. -- patterns[6]: 0xEEAABBAAEEAABBAA
  33. -- patterns[7]: 0xEEBBBBEEEEBBBBEE
  34. -- patterns[8]: 0xFFBBFFEEFFBBFFEE
  35. -- patterns[9]: 0xFFBBFFFFFFBBFFFF
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x1122448811224488
  40. -- patterns[14]: 0xC4800C6843023026
  41. -- patterns[15]: 0xB130031BD8C00C8D
  42. -- patterns[16]: 0xAA00AA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0xDDA1A3F7
  67. ----- HyperTalk script -----
  68. function complexNumbers a,b,o,c,d
  69. if o = "+" then return (a+c)&(the itemdelimiter)&(b+d)
  70. if o = "-" then return (a-c)&(the itemdelimiter)&(b-d)
  71. if o = "*" then return ((a*c)-(b*d))&(the itemdelimiter)&((b*c)+(c*d))
  72. if o = "/" then return (((a*c)/((c^2)+(d^2)))+((b*d)/((c^2)+(d^2))))&(the itemdelimiter)&(((b*c)/((c^2)+(d^2)))+((c*d)/(((c^2)+(d^2))^2)))
  73. if o = "¥" or h = "div" then return (((a*c)DIV((c^2)+(d^2)))+((b*d)DIV((c^2)+(d^2))))&(the itemdelimiter)&(((b*c)DIV((c^2)+(d^2)))+((c*d)DIV(((c^2)+(d^2))^2)))
  74. if o = "mod" then return (((a*c)MOD((c^2)+(d^2)))+((b*d)MOD((c^2)+(d^2))))&(the itemdelimiter)&(((b*c)MOD((c^2)+(d^2)))+((c*d)MOD(((c^2)+(d^2))^2)))
  75. if o = "^" then return exp((c*ln(sqrt((a^2)+(b^2))))-(d*theta(a,b)))*cos((d*ln(sqrt((a^2)+(b^2))))+(c*theta(a,b)))&(the itemdelimiter)&exp((c*ln(sqrt((a^2)+(b^2))))-(d*theta(a,b)))*sin((d*ln(sqrt((a^2)+(b^2))))+(c*theta(a,b)))
  76. if o = "竏š" or h = "root" then return complexNumbers(a,b,"^",c/((c^2)+(d^2)),d/((c^2)+(d^2)))
  77.  
  78. if a = "|" or a = "abs" then return sqrt((b^2)+(o^2))&(the itemdelimiter)&"0"
  79. if a = "sin" then return sin(b)*cosh(o)&(the itemdelimiter)&cos(b)*sinh(o)
  80. if a = "cos" then return cos(b)*cosh(o)&(the itemdelimiter)&sin(b)*sinh(o)
  81. if a = "tan" then return complexnumbers(sin(b)*cosh(o),cos(b)*sinh(o),"/",cos(b)*cosh(o),sin(b)*sinh(o))
  82. if a = "atan" then return ((theta(1-o,b)/2)-(theta(1+o,-b)/2))&(the itemdelimiter)&(ln(((b^2)+((o+1)^2))/((b^2)+((o-1)^2)))/4)
  83. if a = "/" then return (b/((b^2)+(o^2)))&(the itemdelimiter)&(o/((b^2)+(o^2)))
  84. if a = "ln" or a = "log" or a = "loge" then
  85.   if c is a number then return ln(abs(b))&(the itemdelimiter)&(theta(b,o)+(2*pi*c))
  86.   return ln(abs(b))&(the itemdelimiter)&theta(b,o)
  87. end if
  88. if a = "log2" then return complexNumbers(item 1 of complexNumbers("ln",b,o,c),item 2 of complexNumbers("ln",b,o,c),"/",ln(2),0)
  89. if a = "log10" then return complexNumbers(item 1 of complexNumbers("ln",b,o,c),item 2 of complexNumbers("ln",b,o,c),"/",ln(10),0)
  90. if a = "exp" then return (exp(b)*cos(o))&(the itemdelimiter)&(cos(o)*sin(o))
  91. if a = "竏š" or a = "sqrt" or a = "sqr" then return complexnumbers(b,o,"^",0.5,0)
  92. if a = "sgn" then
  93.   if b < 0 then put "-1" into ta
  94.   if b > 0 then put "1" into ta
  95.   if b = 0 then put "0" into ta
  96.   put (the itemdelimiter) after ta
  97.   if o > 0 then put "1" after ta
  98.   if o < 0 then put "-1" after ta
  99.   if o = 0 then put "0" after ta
  100.   return ta
  101. end if
  102. if a = "P>R" then return (b*cos(o))&(the itemdelimiter)&(b*sin(o))
  103. if a = "R>P" then return sqrt((b^2)+(o^2))&(the itemdelimiter)&theta(b,o)
  104. if a = "BC" or a = "BaseConv" or a = "BaseConvert" or a = "BaseConvertReal" then
  105.   put baseconvertreal(b,c,d) into ta
  106.   put (the itemdelimiter) after ta
  107.   put baseconvertreal(o,c,d) after ta
  108.   return ta
  109. end if
  110.  
  111. return "Error: Unsupported operation."
  112. end complexNumbers
  113.  
  114. function cn l,m,n,o,p
  115. return complexNumbers(l,m,n,o,p)
  116. end cn
  117.  
  118. function cpxAdd a,b,c,d
  119. return cn(a,b,"+",c,d)
  120. end cpxAdd
  121.  
  122. function cpxSub a,b,c,d
  123. return cn(a,b,"-",c,d)
  124. end cpxSub
  125.  
  126. function cpxMul a,b,c,d
  127. return cn(a,b,"*",c,d)
  128. end cpxMul
  129.  
  130. function cpxDiv a,b,c,d
  131. return cn(a,b,"/",c,d)
  132. end cpxDiv
  133.  
  134. function cpxPower a,b,c,d
  135. return cn(a,b,"^",c,d)
  136. end cpxPower
  137.  
  138. function cpxLog a,b,v
  139. return cn("ln",a,b,v)
  140. end cpxlog
  141.  
  142. function cpxExp a,b
  143. return cn("exp",a,b)
  144. end cpxExp
  145.  
  146. function cpxSin a,b
  147. return cn("sin",a,b)
  148. end cpxSin
  149.  
  150. function cpxCos a,b
  151. return cn("cos",a,b)
  152. end cpxCos
  153.  
  154. function cpxAbs a,b
  155. return cn("|",a,b)
  156. end cpxAbs
  157.  
  158. function cpxRecip a,b
  159. return cn("/",a,b)
  160. end cpxRecip
  161.  
  162. function cpxSgn a,b
  163. return cn("sgn",a,b)
  164. end cpxSgn
  165.  
  166. function cpxIntDiv a,b,c,d
  167. return cn(a,b,"¥",c,d)
  168. end cpxIntDiv
  169.  
  170. function cpxMod a,b,c,d
  171. return cn(a,b,"mod",c,d)
  172. end cpxMod
  173.  
  174. function cpxSqrt a,b
  175. return cn("sqrt",a,b)
  176. end cpxSqrt
  177.  
  178. function cpxRoot a,b,c,d
  179. return cn(a,b,"竏š",c,d)
  180. end cpxRoot
  181.  
  182. function cpxTan a,b
  183. return cn("tan",a,b)
  184. end cpxTan
  185.  
  186. function cpxstrtoval x
  187. put the itemdelimiter into z
  188. if x is a number then return (x*1)&z&"0"
  189. if the last char of x <> "i" then return "ERROR: Expected complex number here."
  190. if "+" is not in x and "-" is not in x then
  191.   delete last char of x
  192.   return "0"&z&(x*1)
  193. end if
  194. if "+" is in x and "-+" is not in x then
  195.   set the itemdelimiter to "+"
  196.   delete last char of x
  197.   put ((item 1 of x)*1)&z&((item 2 of x)*1) into y
  198.   set the itemdelimiter to z
  199.   return y
  200. end if
  201. if the first char of x is "-" and "+-" is not in x then
  202.   set the itemdelimiter to "-"
  203.   delete last char of x
  204.   put ((item 2 of x)*-1)&z&-((item 3 of x)*1) into y
  205.   set the itemdelimiter to z
  206.   return y
  207. end if
  208. if "-" is in x and "+-" is not in x then
  209.   set the itemdelimiter to "-"
  210.   delete last char of x
  211.   put ((item 1 of x)*1)&z&-((item 2 of x)*1) into y
  212.   set the itemdelimiter to z
  213.   return y
  214. end if
  215. end cpxstrtoval
  216.  
  217. function cpxvaltostr a,b
  218. put a into x
  219. if b<0 then put b after x
  220. if b=0 or b>0 then put "+" & b after x
  221. put "i" after x
  222. return x
  223. end cpxvaltostr
  224.