vocabulary 发表于 2007-4-18 14:24:00

[求助]已知两个点求角度?

<p>各位大侠<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 已知两个点PT1和PT2,如何用VBA求出连接这两个点的线段的角度(弧度),另外知道这条线的角度后,VBA里有没有类似LISP里的POLAR()的函数来求得顺着该角度走X距离的点,先谢谢了!</p>

fjfhgdwfn 发表于 2007-4-18 20:57:00

<p>Public Function fwj(ByVal x As Double, ByVal y As Double) As Double<br/>If x = 0 Then<br/>&nbsp;&nbsp;&nbsp; If y &gt; 0 Then<br/>&nbsp;&nbsp;&nbsp; fwj = 3.14159265358979 / 2<br/>&nbsp;&nbsp;&nbsp; Else<br/>&nbsp;&nbsp;&nbsp; fwj = 3.14159265358979 * 1.5<br/>&nbsp;&nbsp;&nbsp; End If<br/>Else<br/>&nbsp;&nbsp;&nbsp; fwj = Atn(y / x)<br/>&nbsp;&nbsp;&nbsp; If x &gt; 0 And y &gt; 0 Then fwj = fwj<br/>&nbsp;&nbsp;&nbsp; If x &gt; 0 And y &lt;= 0 Then fwj = 2 * 3.14159265358979 + fwj<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; If x &lt; 0 Then fwj = fwj + 3.14159265358979<br/>End If<br/>End Function</p><p>不知道对你有帮助没有</p>
页: [1]
查看完整版本: [求助]已知两个点求角度?