relyt
relyt

Reputation: 679

Find sine in Java

Can anyone give me a quick tip?

For example....how would I find the sine of 90 degrees?

Upvotes: 5

Views: 23085

Answers (6)

wcm
wcm

Reputation: 9281

The sin function in java.lang.Math expects a parameter expressed in radians.

I think you should use Math.sin(Math.toRadians(90))

Upvotes: 19

Darin Dimitrov
Darin Dimitrov

Reputation: 1038800

You could use the Math.sin function where the argument is given in radians. Example:

double result = Math.sin(Math.PI / 2.0);

Upvotes: 13

Lucas
Lucas

Reputation: 3119

use

Math.sin(Math.toRadians(90))

Upvotes: 2

Grzegorz Oledzki
Grzegorz Oledzki

Reputation: 24261

A few tips for you:

What if you combine these two tips?

Upvotes: 5

polygenelubricants
polygenelubricants

Reputation: 383746

http://java.sun.com/j2se/1.6.0/docs/api/java/lang/Math.html

It has a sin(double) method among other mathematical functions. It takes the angle in radian, so you'd have to do the conversion from degree. For that purpose (and others), Math also has the PI constant.

Upvotes: 1

Michael Borgwardt
Michael Borgwardt

Reputation: 346300

Look at the java.lang.Math class.

Upvotes: 0

Related Questions