O'Reilly logo

Java™ Phrasebook by Timothy Fisher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Calculating Trigonometric Functions

// calculating cosine
											double cosine = Math.cos(45);
											// calculating sine
											double sine = Math.sin(45);
											// calculating tangent
											double tangent = Math.tan(45);

The Math class found in the java.lang package has methods for easily calculating all the trigonometric functions. In this phrase, we show how you can easily determine the cosine, sine, and tangent of a given angle. The Math class also has methods for calculating the arc cosine, arc sine, and arc tangent, as well as the hyperbolic sine, cosine, and tangent. Each of these methods accepts a single input parameter of double type and returns a result type of double.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required