兰州人 发表于 2008-9-17 22:08:00

C点作线段AB垂线,且交于B点的解法。

本帖最后由 作者 于 2008-9-17 22:09:27 编辑 <br /><br /> <p></p><p>图示,求C点到AB线段的垂线,且交点于B点.</p><p>程序解决如下</p><p>Sub LS()<br/>Sub LS()<br/>&nbsp; Dim Aa(2) As Variant<br/>&nbsp; Aa(0) = Array(10, 33)<br/>&nbsp; Aa(1) = Array(20, 50)<br/>&nbsp; Aa(2) = Array(25, 50)<br/>&nbsp; Dim pp(0 To 2) As Double, ppp(0 To 2) As Double<br/>&nbsp; Dim Alfa(1) As Double, ll As AcadLine<br/>&nbsp; For ii = 0 To 1<br/>&nbsp;&nbsp;&nbsp; For jj = 0 To 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pp(jj) = Aa(ii)(jj)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ppp(jj) = Aa(ii + 1)(jj)<br/>&nbsp;&nbsp;&nbsp; Next jj<br/>&nbsp;&nbsp;&nbsp; Set ll = ThisDrawing.ModelSpace.AddLine(pp, ppp)<br/>&nbsp;&nbsp;&nbsp; Alfa(ii) = ll.Angle<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp; Next ii<br/>&nbsp; Debug.Print Alfa(1), Alfa(0) * 180 / 3.1415926, Alfa(1) - Alfa(0)<br/>&nbsp; Debug.Print Alfa(0) - Pi / 2, (Alfa(0) - Pi / 2) * 180 / Pi<br/>&nbsp; ll.Rotate ll.StartPoint, Alfa(0) - Pi / 2<br/>End Sub<br/>Function Pi() As Double<br/>&nbsp; Pi = 4 * Atn(1)<br/>End Function</p>

sailorcwx 发表于 2008-9-18 01:15:00

<p>总觉得VBA里面几何分析很重要,这个功能在lisp里面太容易了</p>

兰州人 发表于 2008-9-18 08:33:00

sailorcwx发表于2008-9-18 1:15:00static/image/common/back.gif总觉得VBA里面几何分析很重要,这个功能在lisp里面太容易了

<p>要运行LISP在命令行会滚动一大堆内容,速度不如VBA快。要想提高程序运行速度,VBA效果比LISP好。</p><p>用几何算法,就是要提高速度。在VBA中也可以运行LISP语句。</p><p>ll.Rotate ll.StartPoint, Alfa(0) - Pi / 2与LISP的(command "Rotate" pp,"")是等价的。<br/></p>
页: [1]
查看完整版本: C点作线段AB垂线,且交于B点的解法。