It looks like you need to add a 90 degree offset to the result. Also, this function returns the absolute angle, not the relative angle if thats what your looking for.
This is what I use to calculate absolute angle:
(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
Function CalcAbsAngleToXY(x, y)
Dim mh
Dim dx, dy
Dim lAngle
dx = CDbl(x - getPlayerX)
dy = CDbl(y - getPlayerY)
If dx = 0 Then
If dy = 0 Then
mh = 0
ElseIf dy > 0 Then
mh = PI/2.0
Else
mh = PI*3.0/2.0
End If
ElseIf dy = 0 Then
If dx < 0 Then
mh = 0
Else
mh = PI
End If
Else
If dx < 0 Then
mh = atn(dy/dx) + PI
ElseIf dy < 0 Then
mh = atn(dy/dx) + 2.0*PI
Else
mh = atn(dy/dx)
End If
End If
mh = ((mh * 180.0 / PI) + 90) Mod 360
CalcAbsAngleToXY = mh
End Function