Jump to content

Search the Community

Showing results for tags 'atan'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. This thread is about something odd i noticed with AutoIt's aTan function, that caused me a lot of time to track down. Recently i was writing a program to change GPX files, splitting each set of points into smaller directions. It works by taking the current and next point in the gpx file, calculating the angle between them, and then adding points between them every x meters until it's near enough to the second point. Lather, rinse, repeat. The problem is sometimes the angle the new points would make would go completely the wrong direction, approximately half the time. Hurm... Anyways I eventually discovered that aTan would always return a positive result. This is fine for calculating SLOPE, but for calculating ANGLE this was very annoying. I eventually came up with a work-around that works, but i was wondering if this behavior was intended or not. Example script here, will show the buggy behavior by default. Uncomment line 28 to see the expected behavior #include <GUIConstantsEx.au3> $Form1 = GUICreate("Form1", 318, 288, 192, 124) $Radio1 = GUICtrlCreateRadio("", 160, 120, 17, 17) $Label1 = GUICtrlCreateLabel("Label1", 16, 232, 316, 77) GUISetState(@SW_SHOW) Local $s, $olds, $hwnd=WinGetHandle(ControlGetHandle($Form1,"",$Radio1)) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch $pos = WinGetPos($hwnd) If @error then ContinueLoop $pos2 = MouseGetPos() $dx = $pos2[0] - $pos[0] $dy = $pos2[1] - $pos[1] $angle = ATan($dy/$dx) ;this is the fix, uncomment to see expected (desired) behavior ;~ If $dx < 0 Then $angle -= 3.14159265359 $s = "Pos 1 = "&$pos[0]&" , "&$pos[0]&" Angle= "&($angle*57.295779513)+90&@CRLF&"Pos 2 = "&$pos2[0]&" , "&$pos2[1]&@CRLF&"DX = "&$dx&" DY = "&$dy If $s <> $olds Then $olds = $s GUICtrlSetData($Label1, $s) EndIf WEnd
×
×
  • Create New...