>>Hunter: Thanks. Polar coordinates use (radius, theta) though.
Isn't that what I said?
Well, first of all, your checking if x != 0 (the if(x < 0 || x > 0) statement) comes after the 'y / x' operation is done... so if x == 0, then you'll already have a division by zero error anyways.
I'm not totally sure what you're doing with the angle checking, because atan() will only ever return from -90 to +90. Your checks for theta > 90 etc. will never get run. Actually, I don't think there's any way to get the angle in the proper quadrant without looking at the original x and y coordinates (i.e. as in my post, or Thantos' post, or Micko's).
You should consider revising your method. The deeply nested if's and else's make the code hard to read (and unintuitive), especially without the opening/closing braces to mark where each if/else begins and ends.
Does this work? In this case theta < 0, so (180 - theta) > 180, which is in quadrant 3 or 4. But, if x < 0 and y > 0, clearly the angle is supposed to be in quadrant 2 instead.Code:if(x < 0 && y > 0) theta = 180 - theta;