yoyo520125 发表于 2009-5-22 19:35:00

[求助]请帮忙看下这个程序,急!急!急!

目的是选取任意两点计算方位角,代码如下:<br/>Sub calculateangel()<br/>&nbsp;&nbsp;&nbsp;&nbsp;Dim point1 As Variant<br/>&nbsp;&nbsp;&nbsp;&nbsp;Dim point2 As Variant<br/>&nbsp;&nbsp;&nbsp;&nbsp;p1 = ThisDrawing.Utility.GetPoint(, vbCrLf &amp; "第一点:")<br/>&nbsp;&nbsp;&nbsp;&nbsp;p2 = ThisDrawing.Utility.GetPoint(, vbCrLf &amp; "第二点:")<br/>&nbsp;&nbsp;&nbsp;&nbsp;Const pi As Single = 3.14<br/>&nbsp;&nbsp;&nbsp;&nbsp;Dim x As Double<br/>&nbsp;&nbsp;&nbsp;&nbsp;Dim y As Double<br/>&nbsp;&nbsp;&nbsp;&nbsp;Dim z As Double<br/>&nbsp;&nbsp;&nbsp;&nbsp;Dim ang1to2 As Double<br/>&nbsp;&nbsp;&nbsp;&nbsp;x = point1(0) - point2(0)<br/>&nbsp;&nbsp;&nbsp;&nbsp;y = point1(1) - point2(1)<br/>&nbsp;&nbsp;&nbsp;&nbsp;z = point1(2) - point2(2)<br/>&nbsp;&nbsp;&nbsp;&nbsp;ang1to2 = pi - Sgn(y) * pi / 2 - Atn(y / x)<br/>&nbsp;&nbsp;&nbsp;&nbsp;MsgBox "两点之间的方位角为:" &amp; ang1to2, , "个计算单位"<br/>End Sub<br/>希望高手尽快给个解答!

yoyo520125 发表于 2009-5-24 22:18:00

<p>为什么没有人帮忙看下这个程序啊 ?</p><p>目的就是选取任意两个点计算角度,我不知道哪里出错了。</p><p>我是根据计算两点距离而编辑的程序</p>

yshf 发表于 2009-5-26 19:49:00

怎么将point1改为P1,point2改为P2了!!!!

Sub calculateangel()
    Dim point1 As Variant
    Dim point2 As Variant
    point1 = ThisDrawing.Utility.GetPoint(, vbCrLf & "第一点:")
    point2 = ThisDrawing.Utility.GetPoint(point1, vbCrLf & "第二点:")
    Const pi As Single = 3.14
    Dim x As Double
    Dim y As Double
    Dim z As Double
    Dim ang1to2 As Double
    x = point1(0) - point2(0)
    y = point1(1) - point2(1)
    z = point1(2) - point2(2)
    ang1to2 = pi - Sgn(y) * pi / 2 - Atn(y / x)
    MsgBox "两点之间的方位角为:" & ang1to2, , "个计算单位"
End Sub

清风明月名字 发表于 2013-6-28 18:09:24

谢谢3楼分享,学习一下
页: [1]
查看完整版本: [求助]请帮忙看下这个程序,急!急!急!