Mike Cunningham

Ranch Hand

Posts: 130

posted 15 years ago

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

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

Jim Hall

Ranch Hand

Posts: 162

posted 15 years ago

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().

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

Posts: 130

Jane Griscti

Ranch Hand

Posts: 3141

posted 15 years ago

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.

------------------

Jane Griscti

Sun Certified Programmer for the Javaï¿½ 2 Platform

Co-author Mike Meyers' Java 2 Certification Passport

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.

------------------

Jane Griscti

Sun Certified Programmer for the Javaï¿½ 2 Platform

Co-author Mike Meyers' Java 2 Certification Passport

Jane Griscti

SCJP, Co-author Mike Meyers' Java 2 Certification Passport

Jane Griscti

Ranch Hand

Posts: 3141

posted 15 years ago

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

------------------

Jane Griscti

Sun Certified Programmer for the Javaï¿½ 2 Platform

Co-author Mike Meyers' Java 2 Certification Passport

Jane Griscti

SCJP, Co-author Mike Meyers' Java 2 Certification Passport

Madhav Lakkapragada

Ranch Hand

Posts: 5040

posted 15 years ago

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...

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...

Take a Minute, Donate an Hour, Change a Life

http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81