明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1751|回复: 1

巧妙构思,求出直线上距已知点距离最近的点

[复制链接]
发表于 2006-1-10 13:14:00 | 显示全部楼层 |阅读模式

在明经通道函数下载栏中,发现了一个求直线上离已知点距离最近的点的函数,感到特别复杂,特用以下方法实现,请朋友们提意见

Public Function nearestPoint2Line(point As Variant, lineobj As AcadLine) As Variant

Dim pt1 As Variant, pt2 As Variant, pt3 As Variant, intpt As Variant
Dim pointobj1 As AcadPoint, pointobj2 As AcadPoint
Dim lineobjtemp As AcadLine
Dim mosapce As AcadModelSpace

Set mospace = ThisDrawing.ModelSpace

pt1 = lineobj.StartPoint: pt2 = lineobj.EndPoint
Set pointobj1 = mospace.AddPoint(point)
Set pointobj2 = pointobj1.Mirror(pt1, pt2)
Set lineobjtemp = mospace.AddLine(pointobj1.Coordinates, pointobj2.Coordinates)
intpt = lineobjtemp.IntersectWith(lineobj, acextendno)

lineobjtemp.Delete
pointobj1.Delete
pointobj2.Delete

nearestPoint2Line = intpt

End Function

发表于 2006-1-12 14:35:00 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-27 06:30 , Processed in 0.162459 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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