Is there a function or formula that, given an ordered pair of cartesian points, returns an angle, or even a (sin, cos) pair that points to the input pair from the origin point?
Pic somewhat related
>>8514339
arctan(y/x)
>>8514349
Neat, thanks.
Hol up.
What if x = 0? This equation also is unspecific to whether x is positive or negative. The result has an interval of (-90, 90) and instead should have an interval of [0, 360) like it's a unit circle.
>>8514396
If x=0, then you have no angle.
Also, lrn2 quadrants.
>>8514402
>Hol up
if x=0 then the angle is [math]\pm[/math]90 degrees
>>8514396
arctan(y, x)
>>8514396
[eqn]\arctan(\infty)=-\arctan(-\infty)=\frac{\pi}{2}[/eqn]
You're right, though, case handling is an absolute cunt unless you just use Boolean algebra. The best I can do for making the function [math][0, 2\pi)[/math] is
[eqn]\theta(x, y) = \pi[ (x < 0)+2(x \geq 0)(y < 0)]+\arctan\left( \frac{y}{x}\right)[/eqn]