您现在的位置:

逐点比较法圆弧插补VB程序

根据该插补软件框图(参见http://www.busnc.com/ly/zhudian/yuanhchabu.htm),编制出逐点比较法第一象限逆圆插补VB源程序(仅供参考):

Sub 偏差计算()

    偏差 = Sqr((x动点 - x圆心)  2 + (z动点 - z圆心)  2) - R

End Sub

Sub 插补()

    x动点 = x起点: z动点 = z起点:

    动点象限判别

xx: Select Case 象限标志

        Case 1: 单步连续判断

            If 顺逆标志 = "" Then    '第一象限插补

                Do Until (x动点 - x终点) = 0 And (z动点 - z终点) = 0

                If 偏差 >= 0 Then

                   x动点 = x动点 - 1:

                   Line -Step(0, -x步长), vbRed

                Else

                   z动点 = z动点 + 1:

                   Line -Step(z步长, 0), vbRed

                End If

                   偏差计算

                   动点象限判别

                   If 象限标志 <> 1 Then

                      GoTo xx

                   End If

                   单步连续判断

                Loop

            ElseIf 顺逆标志 = "" Then

                Do Until (x动点 - x终点) = 0 And (z动点 - z终点) = 0

                If 偏差 >= 0 Then

                   z动点 = z动点 - 1:

                   Line -Step(-z步长, 0), vbRed

                Else

                   x动点 = x动点 + 1:

                   Line -Step(0, x步长), vbRed

                End If

                   DoEvents

                   偏差计算

                   动点象限判别

                   If 象限标志 <> 1 Then

                      GoTo xx

                   End If

                Loop

            End If

        Case 2: 单步连续判断

            If 顺逆标志 = "" Then    '第二象限插补

                Do Until (x动点 - x终点) = 0 And (z动点 - z终点) = 0

                If 偏差 >= 0 Then

                   z动点 = z动点 - 1:

                   Line -Step(-z步长, 0), vbRed

                Else

                   x动点 = x动点 - 1:

                   Line -Step(0, -x步长), vbRed

                End If

                   偏差计算

                   动点象限判别

                   If 象限标志 <> 2 Then

                      GoTo xx

                   End If

                Loop

            ElseIf 顺逆标志 = "" Then

                Do Until (x动点 - x终点) = 0 And (z动点 - z终点) = 0

                If 偏差 >= 0 Then

                   x动点 = x动点 + 1:

                   Line -Step(0, x步长), vbRed

                Else

                   z动点 = z动点 + 1:

                   Line -Step(z步长, 0), vbRed

                End If

                   偏差计算

                   动点象限判别

                   If 象限标志 <> 2 Then

                      GoTo xx

                   End If

                Loop

            End If

         Case 3: 单步连续判断

            If 顺逆标志 = "" Then    '第三象限插补

                Do Until (x动点 - x终点) = 0 And (z动点 - z终点) = 0

                If 偏差 >= 0 Then

                   x动点 = x动点 + 1:

                   Line -Step(0, x步长), vbRed

                Else

                   z动点 = z动点 - 1:

                   Line -Step(-z步长, 0), vbRed

                End If

                   DoEvents

                   偏差计算

                   动点象限判别

                   If 象限标志 <> 3 Then

                      GoTo xx

                   End If

                Loop

            ElseIf 顺逆标志 = "" Then

                Do Until (x动点 - x终点) = 0 And (z动点 - z终点) = 0

                If 偏差 >= 0 Then

                   z动点 = z动点 + 1:

                   Line -Step(z步长, 0), vbRed

                Else

                   x动点 = x动点 - 1:

                   Line -Step(0, -x步长), vbRed

                End If

                   偏差计算

                   动点象限判别

                   If 象限标志 <> 3 Then

                      GoTo xx

                   End If

                Loop

            End If

         Case 4: 单步连续判断

            If 顺逆标志 = "" Then    '第三象限插补

                Do Until (x动点 - x终点) = 0 And (z动点 - z终点) = 0

                If 偏差 >= 0 Then

                   z动点 = z动点 + 1:

                   Line -Step(z步长, 0), vbRed

                Else

                   x动点 = x动点 + 1:

                   Line -Step(0, x步长), vbRed

                End If

                   偏差计算

                   动点象限判别

                   If 象限标志 <> 4 Then

                      GoTo xx

                   End If

                Loop

            ElseIf 顺逆标志 = "" Then

                Do Until (x动点 - x终点) = 0 And (z动点 - z终点) = 0

                If 偏差 >= 0 Then

                   x动点 = x动点 - 1:

                   Line -Step(0, -x步长), vbRed

                Else

                   z动点 = z动点 - 1:

                   Line -Step(-z步长, 0), vbRed

                End If

                   偏差计算

                   动点象限判别

                   If 象限标志 <> 4 Then

                      GoTo xx

                   End If

                Loop

            End If

    End Select

End Sub