明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 991|回复: 4

怎样在已知 多段线的 起点 端点 及 凸度条件下 求 圆心坐标?

[复制链接]
发表于 2015-3-8 10:58:40 | 显示全部楼层 |阅读模式
如题,怎样在已知 多段线的 起点 端点 及 凸度条件下  求 圆心坐标?请各位多帮助!谢谢!!
发表于 2015-3-8 11:14:50 来自手机 | 显示全部楼层
这还不简单吗,就三角函数加平面几何
发表于 2015-3-8 14:25:31 | 显示全部楼层
我是初学,起点到终点画一条直线,再画该直线的中垂线,最后求出中垂线和
多线段的交点,两个交点的中点就是圆心坐标。
Public Const PI As Double = 3.1415926
Public Sub demoACR()
Dim ptBase As Variant
Dim objEntity As AcadLWPolyline
Dim PT1(2) As Double '起点
Dim PT2(2) As Double '终点
Dim PT12(2) As Double '中心点
Dim LINE12 As AcadLine 'pt1,pt2画直线
Dim LineZ As AcadLine 'line12的中垂线
ThisDrawing.Utility.GetEntity objEntity, ptBase, "请选择图元:"
PT1(0) = objEntity.Coordinates(0): PT1(1) = objEntity.Coordinates(1): PT1(2) = 0
PT2(0) = objEntity.Coordinates(2): PT2(1) = objEntity.Coordinates(3): PT2(2) = 0
PT12(0) = (PT1(0) + PT2(0)) / 2: PT12(1) = (PT1(1) + PT2(1)) / 2: PT12(2) = 0
Set LINE12 = ThisDrawing.ModelSpace.AddLine(PT1, PT2)
Dim angleZ As Double
angleZ = LINE12.angle + PI / 2
Set LineZ = AddLineReAL(PT12, angleZ, 100)
Dim pt3 As Variant
pt3 = LineZ.IntersectWith(objEntity, acExtendBoth)
Dim PtCen(2) As Double
PtCen(0) = (pt3(0) + pt3(3)) / 2: PtCen(1) = (pt3(1) + pt3(4)) / 2: PtCen(2) = (pt3(2) + pt3(5)) / 2
Stop
End Sub
'根据起点和相对极坐标创建直线
Public Function AddLineReAL(ByVal ptSt As Variant, ByVal angle As Double, ByVal dist As Double) As AcadLine
    Dim ptEn(2) As Double
    ptEn(0) = ptSt(0) + dist * Cos(angle)
    ptEn(1) = ptSt(1) + dist * Sin(angle)
    ptEn(2) = ptSt(2)
    Set AddLineReAL = ThisDrawing.ModelSpace.AddLine(ptSt, ptEn)
End Function
发表于 2015-3-8 18:05:15 | 显示全部楼层
 楼主| 发表于 2015-3-10 10:53:00 | 显示全部楼层
感谢各位大侠的恢复,给的思路 解决了!!谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 12:43 , Processed in 0.170460 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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