明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2577|回复: 4

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

[复制链接]
发表于 2007-4-18 10:00:00 | 显示全部楼层 |阅读模式

各位大侠:

      已知两条相交直线的三个点P1,P2,P3,已知内切圆的半径R1,请问如何求出t1和t2两个切点的位置?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2007-4-20 18:42:00 | 显示全部楼层

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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2007-4-21 10:13:00 | 显示全部楼层
本帖最后由 作者 于 2007-4-21 10:14:40 编辑

多谢楼上的大侠,您的图我看得不是很明白,我贴出自己勉强写出来的程序,运行结果基本达到要求,但t2处有一点问题,圆弧与t2p2直线的切点处总是无法正确连接好,有0.0000017间隙,但p3t1与t1处的切点却没有问题,百思不得其解,请各位帮忙看一看程序到底哪有问题,先谢谢了!

Private Sub Fil()
 Dim Tmp As Variant
 Dim p1(0 To 2) As Double
 Dim p2(0 To 2) As Double
 Dim p3(0 To 2) As Double
 Dim pc(0 To 2) As Double
 Dim t1(0 To 2) As Double
 Dim t2(0 To 2) As Double
 Dim Angp1p2Radian As Double
 Dim Angp1p3Radian As Double
 Dim Angpct1Radian As Double
 Dim Angpct2Radian As Double
 Dim AngJJ1 As Double
 Dim AngJJ2 As Double
 Dim Dstp1pc As Double
 Dim Dstp1t1 As Double
 Dim Dstp1t2 As Double
 
 p1(0) = 5#: p1(1) = 45#: p1(2) = 0#
 p2(0) = 50#: p2(1) = 50#: p2(2) = 0#
 p3(0) = 0#: p3(1) = 0#: p3(2) = 0#
 'p1到p2的角度
 Angp1p2Radian = ThisDrawing.Utility.AngleFromXAxis(p1, p2)
 'p1到p3的角度
 Angp1p3Radian = ThisDrawing.Utility.AngleFromXAxis(p1, p3)
 '算出P2P1P3的角度的一半
 AngJJ1 = ((3.1415926 * 2 - Angp1p3Radian + Angp1p2Radian) / 2)
 Dstp1pc = 1 / Sin(AngJJ1) * dRadius
 Dstp1t1 = Cos(AngJJ1) * Dstp1pc
 Dstp1t2 = Dstp1t1
 AngJJ2 = Angp1p3Radian + AngJJ1
 Tmp = ThisDrawing.Utility.PolarPoint(p1, AngJJ2, Dstp1pc)
 pc(0) = Tmp(0)
 pc(1) = Tmp(1)
 pc(2) = Tmp(2)
 Tmp = ThisDrawing.Utility.PolarPoint(p1, Angp1p3Radian, Dstp1t1)
 t1(0) = Tmp(0)
 t1(1) = Tmp(1)
 t1(2) = Tmp(2)
 Tmp = ThisDrawing.Utility.PolarPoint(p1, Angp1p2Radian, Dstp1t2)
 t2(0) = Tmp(0)
 t2(1) = Tmp(1)
 t2(2) = Tmp(2)
 Angpct1Radian = ThisDrawing.Utility.AngleFromXAxis(pc, t1)
 Angpct2Radian = ThisDrawing.Utility.AngleFromXAxis(pc, t2)
 Call ThisDrawing.ModelSpace.AddLine(p2, t2)
 Call ThisDrawing.ModelSpace.AddArc(pc, dRadius, Angpct2Radian, Angpct1Radian)
 Call ThisDrawing.ModelSpace.AddLine(p3, t1)
End Sub

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2007-4-28 14:43:00 | 显示全部楼层

没有哪位兄长帮一帮小弟吗?

发表于 2011-10-28 15:49:42 | 显示全部楼层
我试过了 是PI的问题  取PI=3.1415927 就没问题了
AngJJ1 = ((3.1415927 * 2 - Angp1p3Radian + Angp1p2Radian) / 2.0)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-29 10:44 , Processed in 0.187967 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表