| 09-07-2007, 03:07 PM | #1 |
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 |
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 |
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 |
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 | |
Quote:
I'm sorry but that makes no sense. |
| 09-07-2007, 05:27 PM | #6 |
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 |
Trigger: test![]() Conditions |
| 09-07-2007, 07:29 PM | #8 |
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 |
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 |
Thanks everyone, I tried something like what Troll-Brain suggested and it worked just fine! |
| 09-08-2007, 10:31 AM | #11 | |
Quote:
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 |
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 | |
I know how abs work >.< No, he don't want 320 but 40 °. My english is too bad to explain why, sorry. Quote:
Not for this, hoppefully ![]() |
