Angle Detection from Left Side

TheOverWhelm

Member
Reaction score
16
Say, when you do Angle Between Points, and it's from Origin and a Unit..
Say the Unit is at 179 Degrees. The function will read it as 179
If the Unit is at 181 Degrees, Angle Between Points will read it as -179. How do you effectively check to make sure the unit is between 2 angles that's dependent on the casting angle?
Edit: Keep in mind I'm making an ability that is cast at a point and checks the possibly-effected units angle with the caster.

Edit: By making both the angle between Origin and Unit positive and the angle between Origin and Cast Point positive, then do Minus one to the other and check the number is between -X and X, it works.
Feels inefficient but I guess it works for now
 

Dirac

22710180
Reaction score
147
By casting angle you mean the facing of the unit?

Abs((Facing of the caster-Angle between caster and target))<=ANGLE or Abs((Facing of the caster-Angle between caster and target))>=-ANGLE or Abs((Facing of the caster-Angle between caster and target))<=ANGLE+360 or Abs((Facing of the caster-Angle between caster and target))>=-ANGLE+360
 

TheOverWhelm

Member
Reaction score
16
I have something like that, now.
if Abs(r)-anglecheck < angleminmax and Abs(r)-anglecheck > -angleminmax
(anglecheck being abs( Angle between Caster and Effected Unit), while r being the a Angle Between Caster and Location Cast)
And from testing, it seems to work.
 

ZakkWylde-

New Member
Reaction score
14
If you dont want 181 to read as -179 (or any number above 180 to read as a negative number), do a check on the number.

set angle = valueYouWant.
If the angle < 0, set angle = angle + 360.

All angles returned will be positive, between 0 and 360.
This is probably also a bit quicker than checking absolute values.

Done. (assuming what you're telling me about angles is true--I never knew it went from -180 to 180)
 

TheOverWhelm

Member
Reaction score
16
I think I'll leave it as it is, tbh. If I did it at a 0 to 360 then the conditions I need will still be a r-anglecheck > X and r-anglecheck < X, there's just be one less function to detect the Absolute.
Maybe later I'll fix it, but not for I'll leave it as is. It runs nice and fine and doesn't lag at all (for me at least). Plus, this whole thing is a bit confusing to think about sometimes.
Currently I'm just messing with abilities I can make ^_^
Perhaps I'll optimize them late more later. First complicated ability is bound to be.. overcomplicated ^_^
 

ZakkWylde-

New Member
Reaction score
14
I dont really understand. It is just ONE if-statement...and it wont even run half of the time. It is SOOOO simple.
I know you may be reluctant to remove or alter your system, but seriously...
if you have to, save the file under a different map name, change your current system to this, test it, and find that its simplicity = win.

Unless there is something i'm REALLY not understanding. If this is the case, I'd love for you to straighten me out.
 

vypur85

Hibernate
Reaction score
803
Have to agree the above post here. It is as simple as turning a negative value to a positive one.

There are some weaknesses of the method though. I have not personally experienced any problems yet so far. But it's just in my mind, thinking in theoretical point of view. Something is bound to give problem. But still... it works for me, in my experience, so far.
 

ZakkWylde-

New Member
Reaction score
14
Have to agree the above post here. It is as simple as turning a negative value to a positive one.

There are some weaknesses of the method though. I have not personally experienced any problems yet so far. But it's just in my mind, thinking in theoretical point of view. Something is bound to give problem. But still... it works for me, in my experience, so far.

The only downside I can think of is if the angle were (periodically) being set higher and higher (such that it went past 360)...With GetUnitFacing(unit), that won't happen.

Also, you COULD modify it for the case that goes past 360--

JASS:
if angle &lt; 0 then
   set angle = angle + 360
else
   set angle = ModuloReal(angle, 360) //you could make this happen as an elseif angle &gt;= 360
endif


This addition doesn't seem too pertinent to GetUnitFacing(unit) though.

EDIT: Upon looking at what ModuloReal also actually does..., you could just (in a situation where the angle might be over 360, cuz otherwise it is not worth the computation)
[ljass]set angle = ModuloReal(GetUnitFacing(yourUnit), 360)[/ljass]. It would always be positive, and always between 0 and 360.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top