# Tan-1 in coords calculations

## Recommended Posts

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 code

```#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)
;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 by malu05

[center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center]

##### Share on other sites

ok... code is wrong.. sec.. ill just fix it!

[center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center]

##### Share on other sites

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

##### Share on other sites

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

nono, 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]

##### Share on other sites

A good example of what im trying to do is here;

http://www.itc.fa.dk/software/ies-math/tri.../sixtrigfn.html

dont 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]

## Create an account

Register a new account

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...