Let’s go back to highschool: if I want to take an x-value and a y-value on a unit circle and get the angle in radians, I use cotangent, right? Which can be done using tan(x/y), right? After spending hours trying to get this to work in Unity, I tried this test:
for (float i = -1; i < 1; i = i + 0.2f) {
for (float j = -1; j < 1; j = j + 0.2f) {
Vector2 test = new Vector2(i, j);
test.Normalize();
Debug.Log("For " + test.x + "," + test.y + ", the alleged cotangent is " + Mathf.Tan(test.x / test.y));
}
}
This confirmed a lot of confusing outputs I was seeing, like “tan(0.5/0.58) = -10.4” I got similarly bizarre results from Mathf.Tan(test.y / test.x).
Evidently I’m smart enough to make it through Algebra 2 and Calculus classes, but I’m not smart enough for this. I do understand that radians can be any number, but I expect to see outputs between negative-pi and pi. Or zero and 2 * pi. Can anyone explain to me what’s causing this? Or at least point me to a suitably condescending tutorial?