My atan2 function:
Here's small visualization what values it returns:
I'll refer to this image:
Red vector (named direction) is direction
Two blue vectors represent range where I want to do something
α (alpha) is "falloff" of direction
Purple vector (v) is the vector which I need to check if it's between two blues.
In other words, I need to check if (v) is between (direction-α) and (direction+α)
Here's what I have atm:
for(var/L in b)
In this piece of code, dirX and dirY are x/y values of (v), 'angle' is angle in degrees of my (v), (L.direction - L.angle/2) and (L.direction + L.angle/2) are (direction-α) and (direction+α).
Code works fine, unless my direction is 180 degree (the -y direction). It checks correctly when (v) is <180, but makes mistake when (v) > -180.
I'm sorry if I failed to explain.
Thank you in advance.