Jump to content

Compass is messed up!?!?


Recommended Posts

*************************SOLVED...Kinda***********************************************************************************************************

Hi, I'm making a compass sort of thing but when I run it i get these results, can any one help me figure out how to convert it to standard degrees.

Here's a representation of what I'm getting.

0

        45             -45



     90         X          -90



       -45             45

               -0

And I was hoping there might be a way to change the values to a standard 360/0-90-180-270-360/0.

I would be SOOOOO grateful for anyone that could help on this matter.

Edited by maestro

Hello, World!... LAME lol

Link to comment
Share on other sites

Maybe you could give us a bit of a head start by posting some of the code you tried. Also, your representation shows 45 degrees so do you want 45 degree increments or 90 degree increments.

You can easily do it in a loop stepping backwards from 360 by the increment. 0/360 270 180 90 or forwards doing the same thing.

And that's it for me for a few days. Shutting down now and I won't be back before Friday at the earliest.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Here's the math that it does to get the angle.

$Pxa= $Px2 - $Px
$Pya= $Py2 - $Py
$in = $Pxa / $Pya
$pi = 4 * ATan(1)
$Dir = ATan($in)*180/$pi

But I Worked out a makeshift solution,

its not the greatest but it works.

Thanks anyways.

Hello, World!... LAME lol

Link to comment
Share on other sites

Finished bug testing the fix, if anyone is having same problem, feel free to copy and edit my solution.

$N = 0
    $E = 0
    $S = 0
    $W = 0

If $Py < $Py2 Then ;True = North
    $N += 1
EndIf
If $Px > $Px2 Then ;True = East
    $E += 1
EndIf
If $Py > $Py2 Then ;True = South
    $S += 1
EndIf
If $Px < $Px2 Then ;True = West
    $W += 1
EndIf
If $Dir < 0 Then
    $Dir = $Dir * (-1)
EndIf
If $N = 1 Then
    If $E = 1 Then
        MsgBox (0,"N'E'",$Dir)
        $N = 0
        $E = 0
    ElseIf $W = 1 Then
        $Dir = $Dir - 90
        $Dir = $Dir * (-1)
        $Dir = $Dir + 270
        MsgBox (0,"N'W'",$Dir)
        $N = 0
        $W = 0
    EndIf
    If ($N + $E + $W) = 1 Then
        MsgBox (0,"N'",$Dir)
        $N = 0
    EndIf
ElseIf $S = 1 Then
    If $E = 1 Then
        $Dir = $Dir - 90
        $Dir = $Dir - 90
        $Dir = $Dir * (-1)
        MsgBox (0,"S'E'",$Dir)
        $E = 0
        $S = 0
    ElseIf $W = 1 Then
        $Dir = $Dir + 180
        MsgBox (0,"S'W'",$Dir)
        $S = 0
        $W = 0
    EndIf
    If ($S + $E + $W) = 1 Then
        $Dir = 180
        MsgBox (0,"S'",$Dir)
        $S = 0
    EndIf
EndIf
If $E = 1 Then
            $Dir = 90
    MsgBox (0,"E'",$Dir)
EndIf
If $W = 1 Then
            $Dir = 270
    MsgBox (0,"W'",$Dir)
EndIf

    ;Resetting values to undetermend.
    $N = 0
    $E = 0
    $S = 0
    $W = 0

If you are going to use this you will have to change the variable names, but don't touch the $N,$E,$S,$W.

You will need to points of data for it to work, a initial position, and an offset position.

Edited by maestro

Hello, World!... LAME lol

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...