关于三角函数的超越方程
小弟要求一个求渐开线的超越方程的解arctan(x1/y1)-tan[arccos(r/sqr(x1^2+y1^2))]+arccos(r/sqr(x1^2+y1^2))-arctan(x2/y2)+
tan[arccos(r/sqr(x2^2+y2^2))]-arccos(r/sqr(x2^2+y2^2))=0
已知x1 x2 y1 y2 求r 例子里面 x1=1.0649 x2=4.0115 y1=63.4908 y2=69.2304 求得r=60.1112
想问下用什么思路做呢,小弟原来编了个用迭代法,现在看来对r1 和r2 的初始值考虑很不恰当,因为x1 x2等的初始值是未定的 不一定在55-60间 ,望各路高手指点 ,非常感谢!!!
Private Sub Command1_Click()
Dim x1 As Double, y1 As Double, r As Double, x2 As Double, y2 As Double, r1 As Double, r2 As Double
x1 = Val(Text1.Text): x2 = Val(Text3.Text): y1 = Val(Text2.Text): y2 = Val(Text4.Text)
r1 = 55: r2 = 65: r = (r1 + r2) / 2
Do While Abs(chaoyue(x1, y1, x2, y2, r)) > 0.00001
r = (r1 + r2) / 2
If chaoyue(x1, y1, x2, y2, r) = 0 Then
Text5.Text = r
Else
If chaoyue(x1, y1, x2, y2, r) < 0 Then
r1 = r
Else
r2 = r
End If
End If
Loop
Text5.Text = r
End Sub
-----------------------------------------------------------------------------------------------
Public Function arccos(x As Double) As Double
Dim tmp As Double
tmp = Sqr(-x * x + 1)
If x = 1 Then
arccos = 0
ElseIf x = -1 Then
arccos = 3.14159
Else
arccos = Atn(-x / tmp) + 2 * Atn(1)
End If
End Function
----------------------------------------------------------------------------------
Public Function chaoyue(x1 As Double, y1 As Double, x2 As Double, y2 As Double, r As Double) As Double
Const pi = 3.1415926
Dim tmpA As Double, tmpB As Double
tmpA = arccos(r / Sqr(x1 ^ 2 + y1 ^ 2))
tmpB = arccos(r / Sqr(x2 ^ 2 + y2 ^ 2))
chaoyue = Atn(x1 / y1) - Tan(tmpA / pi * 180) + tmpA - Atn(x2 / y2) + Tan(tmpB / pi * 180) - tmpB
End Function
--------------------编程问答-------------------- 顶啊 求各路大侠帮忙
--------------------编程问答-------------------- 你不一定要局限在55到65之间呀,可以r1=0.01,r2=89.99
只是多迭代几次而已。
其实,反渐开线函数的迭代,最好用牛顿迭代法,你的这种方法,我曾经也用过,我把它取名叫“大刀砍鬼子迭代法”。 --------------------编程问答-------------------- 砍得好! 易做图加qq啊! 我那好像还是运行不行
补充:VB , 基础类