A. Wolf

Ranch Hand

Posts: 57

posted 12 years ago

Hi,

I'm just testing some math functions. I'm comparing the results to what I get from my calculator and I'm getting different results. for example:

on my calculator cos(89.97) = 0.000523598751674

but in java I get cos( 89.97) = -0.4210561210198809

so I checked google with this query and google also says its -0.421056121

Why would my calculator be wrong?

Then I thought about it logically, if I was trying to solve a right triangle for the adjacent side and knew my hypotenuse to be "c" such that "c" is any positive number above 0, and

cos(89.97) = adjacent/c, then the adjacent = cos(89.97) * c.

adjacent can't be negative so google must be wrong, same goes for java.

so... what did I do wrong?

I'm just testing some math functions. I'm comparing the results to what I get from my calculator and I'm getting different results. for example:

on my calculator cos(89.97) = 0.000523598751674

but in java I get cos( 89.97) = -0.4210561210198809

so I checked google with this query and google also says its -0.421056121

Why would my calculator be wrong?

Then I thought about it logically, if I was trying to solve a right triangle for the adjacent side and knew my hypotenuse to be "c" such that "c" is any positive number above 0, and

cos(89.97) = adjacent/c, then the adjacent = cos(89.97) * c.

adjacent can't be negative so google must be wrong, same goes for java.

so... what did I do wrong?

A. Wolf

Ranch Hand

Posts: 57

posted 12 years ago

Quite right you are and you can do it yourself by multiplying by Math.PI/180 for radians or the inverse to get degrees. Either way, I've looked at the documentation too although your last post seems to suggest otherwise.

here's what I've tried so far with little success

Upon searching for articles elsewhere people have suggested to use radians entirely instead of degrees. I feel betrayed that we were drilled in degrees during math class and barely focused on radians even though the important things in the world ( like java ) uses them.

--edited to be less rude.

[ June 26, 2005: Message edited by: A. Wolf ]

here's what I've tried so far with little success

Upon searching for articles elsewhere people have suggested to use radians entirely instead of degrees. I feel betrayed that we were drilled in degrees during math class and barely focused on radians even though the important things in the world ( like java ) uses them.

--edited to be less rude.

[ June 26, 2005: Message edited by: A. Wolf ]

posted 12 years ago

Try...

Degrees and Radians are measurement of angles (gradians is the third measurement). The cosine() method takes radians. If you have degrees, it must be coverted prior to calling the cosine method.

BTW, I don't think I was implying anything... certainly didn't attempt to sound condesending.

Henry

[ June 26, 2005: Message edited by: Henry Wong ]

Degrees and Radians are measurement of angles (gradians is the third measurement). The cosine() method takes radians. If you have degrees, it must be coverted prior to calling the cosine method.

BTW, I don't think I was implying anything... certainly didn't attempt to sound condesending.

Henry

[ June 26, 2005: Message edited by: Henry Wong ]