Jump to content

Longitude and latitude


jay
 Share

Recommended Posts

Ok, I have an idea of what's going on, but I'm pretty much done with writing it for you. Here's what's left: since you're using angles, you're going to need sin, cos, and probably arcsin and arccos (Asin and Acos in autoit) to get all the angles and positions worked out correctly. Since it's so far out of the ordinary for me, and I have work to do for school, I'm going to leave it up to you to test things and figure it out yourself.

hey thanks for your help.....

Link to comment
Share on other sites

I was doing a Google search for the Multivipers forum (the link to the png file has multivipers in the path) and found this. Thought maybe I could help out, I just joined Multivipers the other day.

Try this, as you drag the mouse over the quadrants it will give you the bearing and miles in a tooltip window which could easily get placed in a mouse click event. Make sure to grab the attached gif file as well so that it all lines up.

Let me know...

#include <misc.au3>
#include <GUIConstants.au3>

;Misc setup
HotKeySet ("{ESC}", "stop")
Opt ("MouseCoordMode", 2)

;Create GUI the same size as the gif
$Bullseye = GUICreate ("Bullseye", 800, 715)
GUICtrlCreatePic (@ScriptDir & "\bullseye.gif", 0, 0, 800, 715)
GUISetState (@SW_SHOW)

;Some default conversion values
$pi = 3.14159265358979
$radToDeg = 180 / $pi

;This is to scale the X and Y values to the values of the mouse cordinates to that of the Bullseye 
$xScale = 180 / 289
$yScale = 180 / 282

;The X and Y cordinates of the center of the Bullseye, depends on the size and location of the pic in the window.
$CenterX = 400 
$CenterY = 347

;The X and Y cordinates of the mouse in relation to the center of the bullseye stated above
$x_locationOnGrid = 0
$y_locationOnGrid = 0

;The two values we want to figure out
$Distance = 0;
$Bearing = 0;


;Get the distance from the center of the Bullseye
Func GetDistance ($side1, $side2)
    return Sqrt ((($side1) ^ 2) + (($side2) ^ 2))   
EndFunc


Func GetBearing ($sideHypot, $sideAdj)
;Must convert the ASin value to Degrees from Radians (radians are the default return type for ASin)
    $angle = ASin($sideAdj / $sideHypot) * $radToDeg

;Determine what quadrant the mouse is in to calculate proper degrees
    If ($x_locationOnGrid > 0) AND ($y_locationOnGrid > 0) Then;Upper Right
        return $angle       
    ElseIf ($x_locationOnGrid > 0) AND ($y_locationOnGrid < 0) Then;Lower Right
        Return 90 - ($angle - 90)
    ElseIf ($x_locationOnGrid < 0) AND ($y_locationOnGrid < 0) Then;Lower Left
        return Abs($angle) + 180
    Else;Upper Left
        return 270 - (ABS($angle) - 90)
    EndIf   
EndFunc

;Func ClickTarget()
;
;EndFunc

Func stop()
    Exit
EndFunc

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        stop()
    EndSelect
    
;Get the mouse position in relation to the center of the bullseye
    $x_locationOnGrid = (MouseGetPos(0) - $CenterX)
    $y_locationOnGrid = ($CenterY - MouseGetPos(1))
    
;Calulate the hypoteneuse of the triangle, which is our distance
    $Distance = GetDistance($x_locationOnGrid  * $xScale,$y_locationOnGrid  * $yScale)
    
;Calculate the angle of the triangle to get our bearing
    $Bearing = GetBearing($Distance,$x_locationOnGrid * $xScale)

;show results in a ToolTip
    ToolTip("Bearing " & Round($Bearing,0) & " - " & Round($Distance,0) & " miles")
    
;   if _IsPressed("01") then
;       ClickTarget()
;   EndIf
WEnd
Edited by Rolln_Thndr
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...