/** * Show how to find the degree of a slope. */ public class Trigonometry { public static void main(String[] args) { /** * All trigonometric functions in java.lang.Math return values in radians. * Therefore, you can use the Math.toDegrees() to convert to degree. * The inverse of sin, cosine and tangent are arcsine, arccosine and arctangent. */ double dSlope = 1; // Let the slope be 1: (0,0), (1,1) double dRadian = Math.atan(dSlope); double dDegree = Math.toDegrees(dRadian); System.out.println(dDegree); // The expected output is: 45 degrees. } }