HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Comparing angles in GUI

09-07-2007, 03:07 PM#1
Nenner
Ok so what I want is a trigger that checks the difference between two angles. Angle(a) - Angle(b) does not work since the angles range from 0-360 and then start over at 0. And I don't know JASS yet so try to keep it in GUI.
09-07-2007, 03:16 PM#2
Troll-Brain
just check which value is the biggest and then do that :
max value - min value



Depends what you want exactly

In this exemple the difference beetween the twice angles is 90 or 270 °
09-07-2007, 03:32 PM#3
Nenner
What I need is a trigger that only runs if the difference between the two angles is <40 degrees. The problem occurs when one of the angles is 320-360 or 0-40 degrees.
09-07-2007, 03:46 PM#4
Troll-Brain
if the difference > 180 then add 180 to the result.
if the difference < 0 then add 180 to the result
09-07-2007, 05:26 PM#5
Nenner
Quote:
Originally Posted by Troll-Brain
if the difference > 180 then add 180 to the result.
if the difference < 0 then add 180 to the result

I'm sorry but that makes no sense.
09-07-2007, 05:27 PM#6
botanic
goto file options and enable negative numbers then get the absolute value of the A1 - A2

It would look like this in GUI:

abs((A1-A2))
09-07-2007, 05:53 PM#7
Troll-Brain
Trigger:
test
Collapse Events
Player - Player 1 (Red) types a chat message containing test
Conditions
Collapse Actions
Set Real1 = 10.00
Set Real2 = 350.00
Set Real = (Abs((Real1 - Real2)))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse Si - Conditions
Real > 180.00
Collapse Alors - Actions
Set Real = (Abs((Real - 360.00)))
Sinon - Actions
09-07-2007, 07:29 PM#8
botanic
my method would take lead function calls which would be more optimized code. One abs function is faster then 2 abs functions and an if then else. Learn to use optimized code early and make it a habit or later you will regret it most likely.
09-07-2007, 08:47 PM#9
moyack
Why not trying this:

Code:
set angle = Acos(Cos(angle))

This would set the angle in a positive value and this can help you to simplify the comparison.
09-07-2007, 08:59 PM#10
Nenner
Thanks everyone, I tried something like what Troll-Brain suggested and it worked just fine!
09-08-2007, 10:31 AM#11
Troll-Brain
Quote:
Originally Posted by botanic
my method would take lead function calls which would be more optimized code. One abs function is faster then 2 abs functions and an if then else. Learn to use optimized code early and make it a habit or later you will regret it most likely.

the second abs is useless, cause you can simply do :
set real = 360 - real

But your solution don't work with my exemple.
I didn't try to optimize but just to make an easy way in gui.
something that he can understand easily
09-08-2007, 11:22 AM#12
botanic
in my experience the "easy way in GUI" (or JASS for that matter) leads to hours upon hours of fixing code at a later date. And I don't understand what you mean my solution doesn't work? if you have |40-360| the answer is 320 thats the value he wanted... also i dont see what is hard to understand about absolute values "when you take the absolute value of a number and it is a negative number, then make that number positive to get the answer, if it is positive then that number is the answer"
09-08-2007, 11:26 AM#13
Troll-Brain
I know how abs work >.<
No, he don't want 320 but 40 °. My english is too bad to explain why, sorry.
Quote:
in my experience the "easy way in GUI" (or JASS for that matter) leads to hours upon hours of fixing code at a later date
.
Not for this, hoppefully