malu05 Posted November 2, 2006 Share Posted November 2, 2006 (edited) Ok what i need is to find the angle between 2 coords in a coordination system, like needed on a map.So when i am at $Posnow and want to go to $posend i must from north (0deg) turn clockwice $y deg and then just walk forward.example:This is my current codeexpandcollapse popup#include <Math.au3> ;Input i give the app $posendX = 558 $posendY = 608 $posnowX = 590 $posnowY = 587 ;prepare for Tan finding the distance from X-Ynow to X-Yend if _Max ( $posendX, $posnowX ) = $posendX Then $a = $posendX - $posnowX msgbox (1,$a,$a) Else $a = $posnowX - $posendX msgbox (1,$a,$a) EndIf if _Max ( $posendY, $posnowY ) = $posendY Then $b = $posendY - $posnowY msgbox (1,$b,$B) Else $b = $posnowY - $posendY msgbox (1,$b,$B) EndIf ;Tan -1 $intfortan = $a / $b $pi = 4 * ATan(1) $radToDeg = 180 / $pi $y = ATan($intfortan) * $radToDeg ;Converts from 90deg system to 360deg system if $posendX <= $posnowX Then $x1 = 1 Else $x1 = 0 EndIf if $posendY >= $posnowY Then $x2 = 1 Else $x2 = 0 EndIf Select Case $x1 = 0 and $x2 = 0 ;nothing Case $x1 = 0 and $x2 = 1 $y = $y + 90 Case $x1 = 1 and $x2 = 1 $y = $y + 180 case $x1 = 1 and $x2 = 0 $y = $y + 270 EndSelect ;result msgbox(1,(Floor($y)),(Floor($y) & " is final deg" ))This is complex and does eat alot of system recourses compared to a maybe smaller code.So anyone got some ideas of how to do this easier or shorter? Edited November 2, 2006 by malu05 [center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center] Link to comment Share on other sites More sharing options...
malu05 Posted November 2, 2006 Author Share Posted November 2, 2006 ok... code is wrong.. sec.. ill just fix it! [center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center] Link to comment Share on other sites More sharing options...
Paulie Posted November 2, 2006 Share Posted November 2, 2006 ok... code is wrong.. sec.. ill just fix it!look at the law of sines, since you know one angle will always be 90', and you can use SolidSnake's '_Distance' UDF (Search for _Distance in S&S) to find all three sides, Sin = Opposite/Hypotenuse Link to comment Share on other sites More sharing options...
malu05 Posted November 2, 2006 Author Share Posted November 2, 2006 look at the law of sines, since you know one angle will always be 90', and you can use SolidSnake's '_Distance' UDF (Search for _Distance in S&S) to find all three sides, Sin = Opposite/Hypotenusenono, the calc was fine, it was just the way the > and < was turning.But anyone got an idea of how to do this more easily? [center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center] Link to comment Share on other sites More sharing options...
malu05 Posted November 2, 2006 Author Share Posted November 2, 2006 A good example of what im trying to do is here;http://www.itc.fa.dk/software/ies-math/tri.../sixtrigfn.htmldont mind about the danish text there but if you pull the red dot, the "Vinkel" gives the result in degrees.My math is just crap, so i wonder if someone can help me out? [center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now