用兩點坐標求線的角度!如果實現!
<P>用两点坐标求线的角度!如果实现!</P> 你可以先将两点连成直线,再查询直线.angle属性 Public Function CalculateLineAngle(ByVal vStartPoint As Variant, ByVal vEndPoint As Variant) As Double<BR> On Error Resume Next<BR> <BR> Dim X As Double<BR> Dim Y As Double<BR> <BR> X = vEndPoint(0) - vStartPoint(0)<BR> Y = vEndPoint(1) - vStartPoint(1)<BR> If (X > 0 And Y > 0) Or (X > 0 And Y < 0) Then CalculateLineAngle = Atn(Y / X)<BR> If (X < 0 And Y > 0) Or (X < 0 And Y < 0) Then CalculateLineAngle = PI + Atn(Y / X)<BR> If X = 0 Then<BR> If Y < 0 Then CalculateLineAngle = -PI / 2<BR> If Y > 0 Then CalculateLineAngle = PI / 2<BR> End If<BR> If Y = 0 Then<BR> If X < 0 Then CalculateLineAngle = PI<BR> If X > 0 Then CalculateLineAngle = 0<BR> End If<BR> If Abs(CalculateLineAngle - 0) < dbJudgeAngle Then CalculateLineAngle = 0<BR> If CalculateLineAngle < 0 Then CalculateLineAngle = 2 * PI + CalculateLineAngle<BR> <BR>End Function <P>还有dbJudgeAngle是我定义的常量</P><P>const dbJudgeAngle=0.001</P> <P>谢谢各位!!!呵~~</P>
<P> </P> 二楼方法直接,三楼是求Y/X正切值再反正切 这函数很有用!
页:
[1]