Reputation:
Really need help with understanding some math functions involving radians.
Say:
double SinA = (Math.sin(B) * a) / b;
Does B
have to be in Radians? After executing, will SinA
be in Radians?
Further down my example:
double Ainv = Math.asin(SinA);
Does the Math.asin()
function only accept Radians? Will Ainv
be in radians after executing?
Last:
double ADeg = Math.toDegrees(Ainv);
Does Math.toDegrees()
function accept radians?
Upvotes: 0
Views: 1070
Reputation: 234635
All the trigonometric functions in Java operate in radians. Think of a radian as being a natural unit for an angle. At school we were taught to think in terms of degrees, or gradians (of which there are 400 in a circle) if you're French!
Since there are 360 degrees, or 2 * PI radians in a circle, to convert a degree amount to a radians one, multiply the degree amount by PI and divide by 180. Math.toDegrees(Ainv);
performs the inverse of this.
In your case SinA
is not an angle but the result of the computation, so it's in neither degrees nor radians.
Upvotes: 1
Reputation: 37645
Does B have to be in Radians?
Yes. Math.sin
works for an input measured in radians.
After executing, will SinA be in Radians?
This question doesn't really make sense. While the input for Math.sin
should be measured in radians, the return value is dimensionless (has no units).
Does the Math.asin() function only accept Radians?
No, it accepts any real number. If the input is between -1.0
and 1.0
the return value will be measured in radians.
Does Math.toDegrees() function accept radians?
Yes. It accepts an angle in radians, and returns an angle measured in degrees.
Upvotes: 2
Reputation: 34900
1) yes, Math.sin()
acccepts angle in radians
2) result of sin
function can not be in radians in mathematical sence. It is just real number
3) argument of Math.asin
is real number, which is sin
result of some angle. But it returns value in radians.
4) Yes, toDegrees
accepts radians and returns degrees.
Upvotes: 2