In the Mike Meyer's Passport to Java it states: The trig functions sin(), cos(), & tan(), all return a double value in radians, not degrees. You can use the method toDegrees() to convert the result. When someone is looking for the value of something using one of these functions....are they looking for an answer in radians or degrees? Also, what's the benefit of being able to convert it to the other type of value? - Mike

These functions do not return a radian value. They return a double value which represents the ratio of sides of a right triangle. The arguments to the methods must be in radians. sin = o/h cos = a/h tan = o/a where o = length of opposite side a = length of adjacent side h = length of hypotenuse side The methods asin(), acos(), atan() return a double value in radians that represents the corresponding angle. This number can then be converted into degrees using toDegrees().

Mike Cunningham
Ranch Hand

Joined: Nov 14, 2000
Posts: 130

posted

0

So, if I was asked to give the cos() value for the following variable:

Hi Mike, Radians represent angular units of measurment based on the value of PI for measuring circles and arcs. This physics presentation gives a bit of an explanation for their use. Radians are commonly used in calculations with results being converted to degrees. Astronomers commonly convert between degrees and radians. If you see an answer to a trig question that shows a result of 30.5 or 280.0 then you'll know that choice is incorrect; radians values won't exceed PI. Hope that helps.

Doubt you'll see a question that would ask you to compute a cos() or sin() value except on a physics exam ------------------ Jane Griscti Sun Certified Programmer for the Javaï¿½ 2 Platform Co-author Mike Meyers' Java 2 Certification Passport

Mike: The answer would be: System.out.println(Math.sin(angle)); // = 1 this represents a ratio as Jim pointed out. That doesn't mean that your second println stmt would fail. Its just a magic with numbers. Your code doesn't deal with units, its just us humans. So, your second stmt will take an input of 1 (radian) and convert it to degrees and output that value which would be 57.??? (degrees). regds. - satya ps: Wasn't there a similar bug in some spaceship launch that caused a mishap. Confusion between degrees and radians or was it units...