float subtraction gives wild answers?
I have a float variable defined as
float var = -Mathf.Atan(y/x);
which gives the expected value of -18 degrees (after converting from rad). However, when I change this line to
float var = 360-Mathf.Atan(y/x);
the value of var becomes ~20,000. Why is this happening? Thanks
Comment
Answer by Alanisaac · Feb 25, 2018 at 03:10 PM
which gives the expected value of -18 degrees (after converting from rad)
Degrees/Radians is the issue. I think you want (2*Math.PI)-Mathf.Atan(y/x);
Answer by roybiv · Feb 26, 2018 at 02:12 AM
Thanks for answering, but I found out what the problem was: me. I was converting to radians after adding 90. Oops. Thanks anyway