1
votes

I'm working on program that lets the user declare values that they already know (like angles and sides). The program will use trigonometry to fill in the blanks. I'm using the class java.lang.Math to do this. I have been using these methods:

Math.sin(Double radians)
Math.cos(Double radians)

Both of those methods require that you convert the value from angles to radians, which I've been doing through:

Math.toRadians(Double angle)

I'm trying to use the inverse functions of sine and cosine (also known as; sin^-1(), asin(), cos^-1(), or acos()). They have methods in the same class, listed as:

Math.asin(Double num)
Math.acos(Double num)

Do they require conversion? Before you pass the variable that represents the angle, do you need to convert it from angle to radian (like I did earlier)?

2
You do not pass angles to inverse functions. You pass a number. But you will need to convert the result if you need it in degrees.Sami Kuhmonen
You'll have to perform conversion to radians if you are using asin, acos etc.user2004685
Instead of guessing, why not check the documentation? It’s pretty clear about this.VGR
The inverse takes a value of the function and returns the angle in radians. How can you use these functions without any understanding of what they mean?duffymo
You do not need any conversations. :) The asin and acos functions work on an arugment that is just some number between -1 and 1. That number between -1 and 1 does not represent an angle, so you do not need to do any conversion. :)Pedro

2 Answers

1
votes

Inverse trigonometric functions are, as they are named, inverse. Since a trigonometric function is a function of the form angle -> value, then the inverse has inverted domain and codomain, value -> angle.

So

Before you pass the variable that represents the angle, do you need to convert it from angle to radian

This makes no sense, since you would convert a value which is not an angle. What you want to do is to convert the result of the inverse function to degrees to obtain the value in the same unit you are using, eg:

double angleInRadians = Math.acos(1);
double angleInDegree = Math.toDegrees(angleInRadians);

So in the end you have

degrees -> radians -> trigonometric function -> value
value -> inverse trigonometric function -> radians -> degrees
0
votes

An inverse sin or cosine function's domain is [-1,1]. So, it would be useful to validate the input before passing it to the method. The result of doing the inverse is an angle. Now, for the result you may want to do conversion from radians to degree. But, you don't need any conversion for the inverse function.