Attribute VB_Name = "hlp_iTan"
Option Explicit
Option Base 0

Public Function iTan(ByVal X As Single, ByVal Y As Single, ByVal XYCenter As Single, ByRef Radius As Single) As Single
  'Dim xLong1 As Long
  'Dim xLong2 As Long
  'Dim xLong3 As Long
  'Dim xSingle1 As Single
  'Dim xSingle2 As Single
  Dim Proportion As Single
  
'  Stop
  'Proportion = (X - XYCenter) / Sqr((Y - XYCenter) ^ 2 + (X - XYCenter))
  If X - XYCenter = 0& Then
    If Y - XYCenter = 0 Then
      'iTan = 0 / 0
      Radius = 0
      Else
      If Y > XYCenter Then
        Radius = (Y - XYCenter)
        iTan = 270 / (180 / 3.1415926536)
        Else
        Radius = -(Y - XYCenter)
        iTan = 90 / (180 / 3.1415926536)
        End If
      End If
    ElseIf Y - XYCenter = 0& Then
    If X > XYCenter Then
      Radius = (X - XYCenter)
      'iTan = 90 / (180 / 3.1415926536)
      Else
      Radius = -(X - XYCenter)
      iTan = 180 / (180 / 3.1415926536)
      End If
    Else
    iTan = Atn((X - XYCenter) / (Y - XYCenter))
    If Y < XYCenter Then
      iTan = 90 / (180 / 3.1415926536) + iTan
      Else
      iTan = 270 / (180 / 3.1415926536) + iTan
      End If
    Radius = Sqr((X - XYCenter) ^ 2 + Abs(Y - XYCenter) ^ 2)
    End If
  End Function

