vocabulary 发表于 2007-4-18 10:00:00

[求助]VBA求两条相交直线内切圆的切点?

<p>各位大侠:</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 已知两条相交直线的三个点P1,P2,P3,已知内切圆的半径R1,请问如何求出t1和t2两个切点的位置?</p>

jkbanana 发表于 2007-4-20 18:42:00

<p>如下图,用解析法可求的要求的点t1, t2的坐标</p><p></p>

vocabulary 发表于 2007-4-21 10:13:00

本帖最后由 作者 于 2007-4-21 10:14:40 编辑 <br /><br /> <p>多谢楼上的大侠,您的图我看得不是很明白,我贴出自己勉强写出来的程序,运行结果基本达到要求,但t2处有一点问题,圆弧与t2p2直线的切点处总是无法正确连接好,有0.0000017间隙,但p3t1与t1处的切点却没有问题,百思不得其解,请各位帮忙看一看程序到底哪有问题,先谢谢了!</p><p>Private Sub Fil()<br/>&nbsp;Dim Tmp As Variant<br/>&nbsp;Dim p1(0 To 2) As Double<br/>&nbsp;Dim p2(0 To 2) As Double<br/>&nbsp;Dim p3(0 To 2) As Double<br/>&nbsp;Dim pc(0 To 2) As Double<br/>&nbsp;Dim t1(0 To 2) As Double<br/>&nbsp;Dim t2(0 To 2) As Double<br/>&nbsp;Dim Angp1p2Radian As Double<br/>&nbsp;Dim Angp1p3Radian As Double<br/>&nbsp;Dim Angpct1Radian As Double<br/>&nbsp;Dim Angpct2Radian As Double<br/>&nbsp;Dim AngJJ1 As Double<br/>&nbsp;Dim AngJJ2 As Double<br/>&nbsp;Dim Dstp1pc As Double<br/>&nbsp;Dim Dstp1t1 As Double<br/>&nbsp;Dim Dstp1t2 As Double<br/>&nbsp;<br/>&nbsp;p1(0) = 5#: p1(1) = 45#: p1(2) = 0#<br/>&nbsp;p2(0) = 50#: p2(1) = 50#: p2(2) = 0#<br/>&nbsp;p3(0) = 0#: p3(1) = 0#: p3(2) = 0#<br/>&nbsp;'p1到p2的角度<br/>&nbsp;Angp1p2Radian = ThisDrawing.Utility.AngleFromXAxis(p1, p2)<br/>&nbsp;'p1到p3的角度<br/>&nbsp;Angp1p3Radian = ThisDrawing.Utility.AngleFromXAxis(p1, p3)<br/>&nbsp;'算出P2P1P3的角度的一半<br/>&nbsp;AngJJ1 = ((3.1415926 * 2 - Angp1p3Radian + Angp1p2Radian) / 2)<br/>&nbsp;Dstp1pc = 1 / Sin(AngJJ1) * dRadius<br/>&nbsp;Dstp1t1 = Cos(AngJJ1) * Dstp1pc<br/>&nbsp;Dstp1t2 = Dstp1t1<br/>&nbsp;AngJJ2 = Angp1p3Radian + AngJJ1<br/>&nbsp;Tmp = ThisDrawing.Utility.PolarPoint(p1, AngJJ2, Dstp1pc)<br/>&nbsp;pc(0) = Tmp(0)<br/>&nbsp;pc(1) = Tmp(1)<br/>&nbsp;pc(2) = Tmp(2)<br/>&nbsp;Tmp = ThisDrawing.Utility.PolarPoint(p1, Angp1p3Radian, Dstp1t1)<br/>&nbsp;t1(0) = Tmp(0)<br/>&nbsp;t1(1) = Tmp(1)<br/>&nbsp;t1(2) = Tmp(2)<br/>&nbsp;Tmp = ThisDrawing.Utility.PolarPoint(p1, Angp1p2Radian, Dstp1t2)<br/>&nbsp;t2(0) = Tmp(0)<br/>&nbsp;t2(1) = Tmp(1)<br/>&nbsp;t2(2) = Tmp(2)<br/>&nbsp;Angpct1Radian = ThisDrawing.Utility.AngleFromXAxis(pc, t1)<br/>&nbsp;Angpct2Radian = ThisDrawing.Utility.AngleFromXAxis(pc, t2)<br/>&nbsp;Call ThisDrawing.ModelSpace.AddLine(p2, t2)<br/>&nbsp;Call ThisDrawing.ModelSpace.AddArc(pc, dRadius, Angpct2Radian, Angpct1Radian)<br/>&nbsp;Call ThisDrawing.ModelSpace.AddLine(p3, t1)<br/>End Sub<br/></p>

vocabulary 发表于 2007-4-28 14:43:00

<p>没有哪位兄长帮一帮小弟吗?</p>

tongji007 发表于 2011-10-28 15:49:42

我试过了 是PI的问题取PI=3.1415927 就没问题了
AngJJ1 = ((3.1415927 * 2 - Angp1p3Radian + Angp1p2Radian) / 2.0)
页: [1]
查看完整版本: [求助]VBA求两条相交直线内切圆的切点?