[求助]VBA求两条相交直线内切圆的切点?
<p>各位大侠:</p><p> 已知两条相交直线的三个点P1,P2,P3,已知内切圆的半径R1,请问如何求出t1和t2两个切点的位置?</p> <p>如下图,用解析法可求的要求的点t1, t2的坐标</p><p></p> 本帖最后由 作者 于 2007-4-21 10:14:40 编辑 <br /><br /> <p>多谢楼上的大侠,您的图我看得不是很明白,我贴出自己勉强写出来的程序,运行结果基本达到要求,但t2处有一点问题,圆弧与t2p2直线的切点处总是无法正确连接好,有0.0000017间隙,但p3t1与t1处的切点却没有问题,百思不得其解,请各位帮忙看一看程序到底哪有问题,先谢谢了!</p><p>Private Sub Fil()<br/> Dim Tmp As Variant<br/> Dim p1(0 To 2) As Double<br/> Dim p2(0 To 2) As Double<br/> Dim p3(0 To 2) As Double<br/> Dim pc(0 To 2) As Double<br/> Dim t1(0 To 2) As Double<br/> Dim t2(0 To 2) As Double<br/> Dim Angp1p2Radian As Double<br/> Dim Angp1p3Radian As Double<br/> Dim Angpct1Radian As Double<br/> Dim Angpct2Radian As Double<br/> Dim AngJJ1 As Double<br/> Dim AngJJ2 As Double<br/> Dim Dstp1pc As Double<br/> Dim Dstp1t1 As Double<br/> Dim Dstp1t2 As Double<br/> <br/> p1(0) = 5#: p1(1) = 45#: p1(2) = 0#<br/> p2(0) = 50#: p2(1) = 50#: p2(2) = 0#<br/> p3(0) = 0#: p3(1) = 0#: p3(2) = 0#<br/> 'p1到p2的角度<br/> Angp1p2Radian = ThisDrawing.Utility.AngleFromXAxis(p1, p2)<br/> 'p1到p3的角度<br/> Angp1p3Radian = ThisDrawing.Utility.AngleFromXAxis(p1, p3)<br/> '算出P2P1P3的角度的一半<br/> AngJJ1 = ((3.1415926 * 2 - Angp1p3Radian + Angp1p2Radian) / 2)<br/> Dstp1pc = 1 / Sin(AngJJ1) * dRadius<br/> Dstp1t1 = Cos(AngJJ1) * Dstp1pc<br/> Dstp1t2 = Dstp1t1<br/> AngJJ2 = Angp1p3Radian + AngJJ1<br/> Tmp = ThisDrawing.Utility.PolarPoint(p1, AngJJ2, Dstp1pc)<br/> pc(0) = Tmp(0)<br/> pc(1) = Tmp(1)<br/> pc(2) = Tmp(2)<br/> Tmp = ThisDrawing.Utility.PolarPoint(p1, Angp1p3Radian, Dstp1t1)<br/> t1(0) = Tmp(0)<br/> t1(1) = Tmp(1)<br/> t1(2) = Tmp(2)<br/> Tmp = ThisDrawing.Utility.PolarPoint(p1, Angp1p2Radian, Dstp1t2)<br/> t2(0) = Tmp(0)<br/> t2(1) = Tmp(1)<br/> t2(2) = Tmp(2)<br/> Angpct1Radian = ThisDrawing.Utility.AngleFromXAxis(pc, t1)<br/> Angpct2Radian = ThisDrawing.Utility.AngleFromXAxis(pc, t2)<br/> Call ThisDrawing.ModelSpace.AddLine(p2, t2)<br/> Call ThisDrawing.ModelSpace.AddArc(pc, dRadius, Angpct2Radian, Angpct1Radian)<br/> Call ThisDrawing.ModelSpace.AddLine(p3, t1)<br/>End Sub<br/></p> <p>没有哪位兄长帮一帮小弟吗?</p> 我试过了 是PI的问题取PI=3.1415927 就没问题了AngJJ1 = ((3.1415927 * 2 - Angp1p3Radian + Angp1p2Radian) / 2.0)
页:
[1]