proc/get_fullcircle_dir(atom/ref,atom/target,startpx,startpy,endpx,endpy)
if(!ref || !target) return 0
var/dy
var/dx
if(startpx)
dy = endpy - startpy
dx = endpx - startpx
world << "dx: [dx]"
world << "dy: [dy]"
else
dy = target.y - ref.y
dx = target.x - ref.x
if(!dy)
world << "test1"
return (dx>=0) ? 90 : 270
. = arctan(dx/dy)
world << "arctan: [.]"
if(dy<0)
world << "test2"
. += 180
else if(dx<0)
world << "test3"
.+=360
proc/arctan(x)
var/y=arcsin(x/sqrt(1+x*x))
if(x>=0) return y
return -y
Problem description:
This is making me pull my hair out. I don't understand how everything can work just fine for every quadrent but the lower right. Seems like I've tried everything but I just can't figure out why I click for a 90 degree angle, it does it fine, but then if I ask it to do anything between 90 and 180, it wigs out and thinks it's like, 56 with the arctangaent and then it will add 180 to that which puts it into the lower-left and upper-left quadrents.
Help, please?
What it's supposed to do is return an angle out of 359 degrees, angle 0 being north.
Even if you did want to return only positive though, you could just use "return abs(y)"