In Java, there are the following mathematical trigonometric functions:
public class TrigonometricFunctions {
public static void main(String[] args) {
double pi, sin, cos, tan, asin, acos, atan, rad, deg;
// The double value that is closer than any other to pi,
// the ratio of the circumference of a circle to its diameter.
pi = Math.PI;
// Returns the trigonometric sine of an angle.
sin = Math.sin(pi);
// Returns the trigonometric cosine of an angle.
cos = Math.cos(pi);
// Returns the trigonometric tangent of an angle
tan = Math.tan(pi);
// Returns the arc sine of a value.
// the returned angle is in the range -pi/2 through pi/2.
asin = Math.asin(1.0);
// Returns the arc cosine of a value.
// the returned angle is in the range 0.0 through pi.
acos = Math.acos(0);
// Returns the arc tangent of a value.
// the returned angle is in the range -pi/2 through pi/2.
atan = Math.atan(1.0);
// Converts an angle measured in degrees to an approximately equivalent angle measured in radians.
// The conversion from degrees to radians is generally inexact.
rad = Math.toRadians(90);
// Converts an angle measured in radians to an approximately equivalent angle measured in degrees.
// The conversion from radians to degrees is generally inexact.
// users should not expect cos(toRadians(90.0)) to exactly equal 0.0.
deg = Math.toDegrees(1.5707963267948966);
System.out.println("PI: " + pi);
System.out.println("sin: " + sin);
System.out.println("cos: " + cos);
System.out.println("tan: " + tan);
System.out.println("asin: " + asin);
System.out.println("acos: " + acos);
System.out.println("atan: " + atan);
System.out.println("rad: " + rad);
System.out.println("deg: " + deg);
}
}
PI: 3.141592653589793
sin: 1.2246467991473532E-16
cos: -1.0
tan: -1.2246467991473532E-16
asin: 1.5707963267948966
acos: 1.5707963267948966
atan: 0.7853981633974483
rad: 1.5707963267948966
deg: 90.0