Jump to content

Radian to Degrees issue.


Recommended Posts

Okay. I'm trying to find the measure of an angle. My code is what I think should be working but some funny things are happening. About 2/3 times, it doesn't even give me an angle and the other 1/3 of the time, the numbers are ususally between 50-90 or -50 through -90 though I don't know why. I have iscolated the problem to the _degree() thing but I'm not sure what's wrong with it. Many of the commented out things are my attempts at fixing it so i'll leave them in here. I might not of done something right so please try the things I tried again. Also, I am including the math.au3. thanks.

Func code()
    $win = WinGetPos("    P§   ")
    $pos = MouseGetPos()
    $x_move = $pos[0] - $win[0] - 105
    $y_move = $pos[1] - $win[1] - 97
    $distance = ""
    If $text <> "" Then
        $distance = Sqrt ( ($x_move - $x_old)^2 + ($y_move - $y_old)^2 )
        $feet1 = Floor($distance / 12) 
        $feet2 = Round($distance - ($feet1 * 12),1)
        $feet = " OR " & $feet1 & "'" & $feet2 & '" '
       ;$y_move1 = _Radian( $y_move )
       ;$y_old1 = _Radian( $y_old )
       ;$x_move1 = _Radian( $x_move )
       ;$x_old1 = _Radian( $x_old )
       ;$value1 = ATan(($y_move1 - $y_old1)/($x_move1 - $x_old1))
       ;$value = _Degree($value1)
        $value = _Degree( ATan(($y_move - $y_old)/($x_move - $x_old)) )
       ;MsgBox(0,"",$value & "   " & ($y_move1 - $y_old1)/($x_move1 - $x_old1))
        $text = $text & "(" & $x_move & "," & $y_move & ") Distance is: " & $distance & $feet & $value & @CRLF
    EndIf
    If $text = "" Then $text = "(" & $x_move & "," & $y_move & ")" & @CRLF
    $x_old = $x_move
    $y_old = $y_move
    GUICtrlCreateInput($text,50,400,700,150,"0x00201004")
    GUISetState()
    
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...