📄 atan2.txt
字号:
描述:matlab的Atan2函数与vb.net的Atan2函数计算结果并不一致。该程序用vb.net实现了matlab的Atan2函数。
Function Atan2 in matlab is different from that in vb.net. The program use vb.net to realize Atan2 function in matlab.
'y is the imaginary part of a complex and x is the real part
Public Shared Function matlab_Atan2(ByVal y As Double, ByVal x As Double) As Double
Dim value As Double
Dim m As Integer = 2 * Math.Sign(x) + Math.Sign(y)
If x = 0 AndAlso y = 0 Then
Return 0
End If
If y = 0 AndAlso x <> 0 Then
If x > 0 Then
Return 0
Else
Return -Math.PI
End If
End If
If x = 0 AndAlso y <> 0 Then
If y > 0 Then
Return Math.PI / 2
Else
Return -1 * Math.PI / 2
End If
End If
value = Math.Atan(y / x)
Select Case m
Case 3 'sign(x,y)=(+,+)
Return value
Case -3 'sign(x,y)=(-,-)
Return value - Math.PI
Case 1 'sign(x,y)=(+,-)
Return value
Case Else 'case -1 'sign(x,y)=(-,+)
Return value + Math.PI
End Select
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -