vb 求两圆交点,已知两圆半径何圆心位置,如何求其交点
展开全部
1. 写出两个圆的方程
2. 循环小圆的x值的范围,每个x对应两个y, 也就是确定了两个点。
3. 把这两个点的位置代入大圆的方程,看能否成立,如成立,就用line做线
2. 循环小圆的x值的范围,每个x对应两个y, 也就是确定了两个点。
3. 把这两个点的位置代入大圆的方程,看能否成立,如成立,就用line做线
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
'新建工程
Private a As Single, b As Single, r As Single
Private x As Single, y As Single, z As Single
Private Sub Form_Paint()
a = 2000: b = 2000: r = 1000 '圆参数
Me.Circle (a, b), r, vbRed
x = 3500: y = 2000: z = 1500 '圆参数
Me.Circle (x, y), z, vbRed
Call CirEx
End Sub
'求两点距离
Private Function GetLen(px1 As Single, py1 As Single, px2 As Single, py2 As Single) As Single
GetLen = Sqr((px1 - px2) ^ 2 + (py1 - py2) ^ 2)
End Function
'画切线,x,y为圆外点纵横坐标,
Private Sub CirEx()
Dim i As Single, j As Single, s As Single
s = 0.6 '误差
For i = a - r To a + r '横坐标
j = b + Sqr(r ^ 2 - (i - a) ^ 2) '上纵坐标
If Abs(GetLen(i, j, a, b) - r) < s And Abs(GetLen(i, j, x, y) - z) < s Then Exit For
Next i
j = b + Sqr(r ^ 2 - (i - a) ^ 2) '上纵坐标
Me.Line (i, j)-(x, y), vbRed
j = b - Sqr(r ^ 2 - (i - a) ^ 2) '上纵坐标
Me.Line (i, j)-(x, y), vbRed
End Sub
Private a As Single, b As Single, r As Single
Private x As Single, y As Single, z As Single
Private Sub Form_Paint()
a = 2000: b = 2000: r = 1000 '圆参数
Me.Circle (a, b), r, vbRed
x = 3500: y = 2000: z = 1500 '圆参数
Me.Circle (x, y), z, vbRed
Call CirEx
End Sub
'求两点距离
Private Function GetLen(px1 As Single, py1 As Single, px2 As Single, py2 As Single) As Single
GetLen = Sqr((px1 - px2) ^ 2 + (py1 - py2) ^ 2)
End Function
'画切线,x,y为圆外点纵横坐标,
Private Sub CirEx()
Dim i As Single, j As Single, s As Single
s = 0.6 '误差
For i = a - r To a + r '横坐标
j = b + Sqr(r ^ 2 - (i - a) ^ 2) '上纵坐标
If Abs(GetLen(i, j, a, b) - r) < s And Abs(GetLen(i, j, x, y) - z) < s Then Exit For
Next i
j = b + Sqr(r ^ 2 - (i - a) ^ 2) '上纵坐标
Me.Line (i, j)-(x, y), vbRed
j = b - Sqr(r ^ 2 - (i - a) ^ 2) '上纵坐标
Me.Line (i, j)-(x, y), vbRed
End Sub
更多追问追答
追答
我看不到错误定位在哪,你可以设置断点调试,可能是参数设置不合理,不明白的地方HI我。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询