2 ty9413 ty9413 于 2016.05.02 15:03 提问

求VB大神帮助,想求一个公式的最大值,最小值,及对应的角度 5C

θ=输入值

S= 输入值

x=0 to 360
e=0.2S
h=1.2S
a=0.7S
X1=a*sin(θ+x)
y1=-a*cos(θ+x)
x2=e
y2=h+S
b= Math.Sqrt((x1 - x2) ^ 2 + (y1 - y2) ^ 2)
求b的最大值bmax及对应的角度(x值),最小值bmin和最小值的角度(x值)
θ 和S 文本输入框让用户自定义

我用的是VB.NET
想要lable输出这样的结果,
最大值1234, 角度123
最小值123,角度12

1个回答

ty9413
ty9413   2016.05.02 15:16

vb.NET软件
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Me.TextBox1.Text = "" Then
MsgBox("请输入值", , "提示信息")
Else
Dim l1 As Double 'CB
Dim l2 As Double 'AB
Dim S As Double '从动杆工作行程
Dim a As Double '原动杆0A长度
Dim θ0 As Double '曲柄起始角度
'Dim Q1 As Double '升程运动对应的曲柄转角
' Dim Q2 As Double '最高位置停留对应的曲柄转角
'Dim Q3 As Double '降程运动对应的曲柄转角
'Dim Q4 As Double '最低位置停留对应的曲柄转角
Dim h As Double '滑块最低点到凸轮中心
Dim Ee As Double
Dim XB As Double
Dim XB1 As Double
Dim YB As Double
Dim XD As Double
Dim YD As Double
Dim x As Double
Dim max As Double
Dim min As Double
Dim J As Integer
Dim K As Double
Dim u As Double
Dim v As Double
Dim i As Double
Dim θ(0 To 360) As Double
For x = 1 To 360

            S = Me.TextBox1.Text
            a = S * 0.7             '曲柄AB
            h = S * 1.2
            Ee = Me.TextBox3.Text
            θ0 = Me.TextBox4.Text
            XB = a * Math.Sin(θ0 + x)
            YB = -a * Math.Cos(θ0 + x)
            XD = Ee
            YD = h + S
            θ(x) = Math.Sqrt((XB - XD) ^ 2 + (YB - YD) ^ 2)
        Next x
        For i = 2 To 360
            If θ(i) > max Then max = θ(i)
            K = YB
            J = XB


        Next i
        u = Math.Asin(J / a) * (360 / (2 * Math.PI))

        For x = 1 To 360

            S = Me.TextBox1.Text
            a = S * 0.7             '曲柄AB
            h = S * 1.2
            Ee = Me.TextBox3.Text
            θ0 = Me.TextBox4.Text
            XB1 = a * Math.Sin(θ0 + x)
            YB = -a * Math.Cos(θ0 + x)
            XD = Ee
            YD = h + S
            θ(x) = Math.Sqrt((XB1 - XD) ^ 2 + (YB - YD) ^ 2)
        Next x
        min = θ(1)

        For i = 2 To 360
            If θ(i) < min Then min = θ(i)

        Next i

        'Q1 = Me.TextBox5.Text
        'Q2 = Me.TextBox6.Text
        ' Q3 = Me.TextBox7.Text
        'Q4 = Me.TextBox8.Text
        l1 = (max + min) / 2
        l2 = (max - min) / 2

        v = Math.Asin(0.5) * (360 / (2 * Math.PI))

        Me.Label6.Text = "铰销D至轴的最小距离=" & h
        Me.Label7.Text = "曲柄AB=" & a
        Me.Label8.Text = "曲柄起始角度=" & θ0
        Me.Label9.Text = "偏心距离=" & Ee
        Me.Label10.Text = "fmax=" & Format(max, "##.00")
        Me.Label11.Text = "fmin=" & Format(min, "##.00")
        Me.Label12.Text = "杆CD=" & Format(l1, "##.00")
        Me.Label17.Text = "杆AB=" & Format(l2, "##.00")
        Me.Label18.Text = "度" & u& v


    End If

End Sub

    我自己弄的,但是值不对
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!