明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2385|回复: 3

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

[复制链接]
发表于 2009-5-22 19:35:00 | 显示全部楼层 |阅读模式
目的是选取任意两点计算方位角,代码如下:
Sub calculateangel()
    Dim point1 As Variant
    Dim point2 As Variant
    p1 = ThisDrawing.Utility.GetPoint(, vbCrLf & "第一点:")
    p2 = ThisDrawing.Utility.GetPoint(, 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
希望高手尽快给个解答!
 楼主| 发表于 2009-5-24 22:18:00 | 显示全部楼层

为什么没有人帮忙看下这个程序啊 ?

目的就是选取任意两个点计算角度,我不知道哪里出错了。

我是根据计算两点距离而编辑的程序

发表于 2009-5-26 19:49:00 | 显示全部楼层
怎么将point1改为P1,point2改为P2了!!!!
  1. Sub calculateangel()
  2.     Dim point1 As Variant
  3.     Dim point2 As Variant
  4.     point1 = ThisDrawing.Utility.GetPoint(, vbCrLf & "第一点:")
  5.     point2 = ThisDrawing.Utility.GetPoint(point1, vbCrLf & "第二点:")
  6.     Const pi As Single = 3.14
  7.     Dim x As Double
  8.     Dim y As Double
  9.     Dim z As Double
  10.     Dim ang1to2 As Double
  11.     x = point1(0) - point2(0)
  12.     y = point1(1) - point2(1)
  13.     z = point1(2) - point2(2)
  14.     ang1to2 = pi - Sgn(y) * pi / 2 - Atn(y / x)
  15.     MsgBox "两点之间的方位角为:" & ang1to2, , "个计算单位"
  16. End Sub
发表于 2013-6-28 18:09:24 | 显示全部楼层
谢谢3楼分享,学习一下
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-29 05:28 , Processed in 0.153458 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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