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/> Dim Aa(2) As Variant<br/> Aa(0) = Array(10, 33)<br/> Aa(1) = Array(20, 50)<br/> Aa(2) = Array(25, 50)<br/> Dim pp(0 To 2) As Double, ppp(0 To 2) As Double<br/> Dim Alfa(1) As Double, ll As AcadLine<br/> For ii = 0 To 1<br/> For jj = 0 To 1<br/> pp(jj) = Aa(ii)(jj)<br/> ppp(jj) = Aa(ii + 1)(jj)<br/> Next jj<br/> Set ll = ThisDrawing.ModelSpace.AddLine(pp, ppp)<br/> Alfa(ii) = ll.Angle<br/> <br/> Next ii<br/> Debug.Print Alfa(1), Alfa(0) * 180 / 3.1415926, Alfa(1) - Alfa(0)<br/> Debug.Print Alfa(0) - Pi / 2, (Alfa(0) - Pi / 2) * 180 / Pi<br/> ll.Rotate ll.StartPoint, Alfa(0) - Pi / 2<br/>End Sub<br/>Function Pi() As Double<br/> Pi = 4 * Atn(1)<br/>End Function</p> <p>总觉得VBA里面几何分析很重要,这个功能在lisp里面太容易了</p> 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]