|
3楼
楼主 |
发表于 2003-4-24 22:58:00
|
只看该作者
Const pi As Double = 3.14159265359
z! E8 |( b/ |Private Function Arccos(x As Double, n As Long) ' n 为函数精度,建议为1005 y7 V1 E, b* R1 Q7 |3 P
Select Case x9 o# X/ u G+ m) e
Case 1
0 y7 Q0 K7 @/ ?1 m- o( ]0 A Arccos = 0- S# \4 {* _* u- t/ T, G" A
Case -17 O7 I0 F% k8 O/ F1 F8 x3 E
Arccos = pi
6 E/ Q9 D5 N) f: ^/ V Case -1 To 1
, j3 X9 r" c1 k) x0 `; u Dim dx As Double, y As Double, i As Long
: |! k9 ^! t8 f3 n9 a dx = x / n
0 O8 d) C4 e3 @4 W For i = 1 To n
. A4 a/ d# V. U% [9 y- K y = y + (-1 / Sqr(1 - (dx * i + dx / 2) ^ 2)) * dx
/ B% z. T' [' n; ]* h, D4 ? Next ^8 P9 \% H& [0 a$ O1 r
Arccos = y + pi / 2* K; h& Z# S/ r2 F0 z
Case Else
9 x& }: ?) W. `. ? '异常
4 p% W T+ y7 P% O% ^# H* C End Select3 d2 |) A+ O( P1 G0 }
End Function6 X7 ?% }; n: [& {! r* L
4 K" i- X- m9 I! o B; m. N% o" L搞定了 |
|