List of usage examples for java.lang Math toRadians
public static double toRadians(double angdeg)
From source file:MathTest.java
public static void main(String args[]) { int angles[] = { 0, 30, 45, 60, 90, 180 }; for (int i = 0, n = angles.length; i < n; i++) { double rad = Math.toRadians(angles[i]); System.out.println("Angle: " + angles[i]); System.out.println(" Sine : " + Math.sin(rad)); System.out.println(" Cosine : " + Math.cos(rad)); System.out.println(" Tangent: " + Math.tan(rad)); }//from w ww . j a va2 s . c om }
From source file:TrigFun.java
public static void main(String[] args) { double rads, degs, tanA, coTanA; // Obtain angle in degrees from user degs = 120d;// w w w.ja v a 2 s . c om // Convert degrees to radian rads = Math.toRadians(degs); // Calculate tangent tanA = Math.tan(rads); System.out.println("Tangent = " + tanA); // Calculate cotangent coTanA = 1.0 / Math.tan(rads); System.out.println("Cotangent = " + coTanA); // Calculate arc-tangent rads = Math.atan(tanA); degs = Math.toDegrees(rads); System.out.println("Arc tangent: " + degs); // Calculate arc-cotangent rads = Math.atan(1 / coTanA); degs = Math.toDegrees(rads); System.out.println("Arc cotangent: " + degs); }
From source file:HypFun.java
public static void main(String[] args) { double rads, degs, sinHA, cosHA, tanHA, asinHA; // Obtain angle in degrees from user degs = 20d;/*w ww.j av a2s. com*/ // Convert degrees to radian rads = Math.toRadians(degs); // Calculate hyperbolic sine sinHA = (Math.exp(rads) - Math.exp(-rads)) / 2; System.out.println("Hyperbolic sine = " + sinHA); // Calculate Hyperbolic cosine cosHA = (Math.exp(rads) + Math.exp(-rads)) / 2; System.out.println("Hyperbolic cosine = " + cosHA); // Calculate hyperbolic tangent tanHA = sinHA / cosHA; System.out.println("Hyperbolic tangent = " + tanHA); // Calculate hyperbolic arc-sine asinHA = Math.log(sinHA + Math.sqrt((sinHA * sinHA) + 1.0)); degs = Math.toDegrees(asinHA); System.out.println("Arc hyperbolic sine = " + degs); }
From source file:MainClass.java
public static void main(String args[]) { double theta = 120.0; System.out.println(theta + " degrees is " + Math.toRadians(theta) + " radians."); theta = 1.312;//from w ww .j a v a 2 s .c o m System.out.println(theta + " radians is " + Math.toDegrees(theta) + " degrees."); }
From source file:Main.java
public static void main(String[] args) { for (int i = 0; i <= 180; i++) { double angleRad = Math.toRadians(i); AffineTransform at = createRandomTransform(angleRad); double extractedAngleRad = extractAngle(at); System.out/*from w w w.j av a 2 s .c om*/ .println("In: " + Math.toDegrees(angleRad) + " " + "Out " + Math.toDegrees(extractedAngleRad)); } }
From source file:TrigSolv.java
public static void main(String[] args) { double a, b, c, angleA, radA; // Apllying Pythagoras' Theorem // Obtain sides from user System.out.println("Side c in terms of sides a and b"); a = 10d;//from w w w. j av a 2s. c o m b = 20d; c = Math.sqrt((a * a) + (b * b)); System.out.println("Side c = " + c); // Using side/angle formula System.out.println("Side c in terms of side b and angle A"); b = 30d; angleA = 20d; radA = Math.toRadians(angleA); c = b * Math.tan(radA); System.out.println("Side c = " + c); }
From source file:TrigonometricDemo.java
public static void main(String[] args) { double degrees = 45.0; double radians = Math.toRadians(degrees); System.out.format("The value of pi is %.4f%n", Math.PI); System.out.format("The sine of %.1f degrees is %.4f%n", degrees, Math.sin(radians)); System.out.format("The cosine of %.1f degrees is %.4f%n", degrees, Math.cos(radians)); System.out.format("The tangent of %.1f degrees is %.4f%n", degrees, Math.tan(radians)); System.out.format("The arcsine of %.4f is %.4f degrees %n", Math.sin(radians), Math.toDegrees(Math.asin(Math.sin(radians)))); System.out.format("The arccosine of %.4f is %.4f degrees %n", Math.cos(radians), Math.toDegrees(Math.acos(Math.cos(radians)))); System.out.format("The arctangent of %.4f is %.4f degrees %n", Math.tan(radians), Math.toDegrees(Math.atan(Math.tan(radians)))); }
From source file:TrigonometricDemo.java
public static void main(String[] args) { double degrees = 45.0; double radians = Math.toRadians(degrees); System.out.println("The value of pi is " + Math.PI); System.out.println("The sine of " + degrees + " is " + Math.sin(radians)); System.out.println("The cosine of " + degrees + " is " + Math.cos(radians)); System.out.println("The tangent of " + degrees + " is " + Math.tan(radians)); System.out.println("The arc sine of " + Math.sin(radians) + " is " + Math.toDegrees(Math.asin(Math.sin(radians))) + " degrees"); System.out.println("The arc cosine of " + Math.cos(radians) + " is " + Math.toDegrees(Math.acos(Math.cos(radians))) + " degrees"); System.out.println("The arc tangent of " + Math.tan(radians) + " is " + Math.toDegrees(Math.atan(Math.tan(radians))) + " degrees"); }
From source file:lambertmrev.LambertMRev.java
/** * @param args the command line arguments *//*from w w w .ja v a 2 s . c om*/ public static void main(String[] args) { // Want to test the Lambert class so you can specify the number of revs for which to compute //System.out.print("this is the frames tutorial \n"); try { Frame inertialFrame = FramesFactory.getEME2000(); TimeScale utc = TimeScalesFactory.getTAI(); AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, utc); double mu = 3.986004415e+14; double a = 24396159; // semi major axis in meters double e = 0.72831215; // eccentricity double i = Math.toRadians(7); // inclination double omega = Math.toRadians(180); // perigee argument double raan = Math.toRadians(261); // right ascension of ascending node double lM = 0; // mean anomaly Orbit initialOrbit = new KeplerianOrbit(a, e, i, omega, raan, lM, PositionAngle.MEAN, inertialFrame, initialDate, mu); //KeplerianPropagator kepler = new KeplerianPropagator(initialOrbit); // set geocentric positions Vector3D r1 = new Vector3D(-6.88999e3, 3.92763e4, 2.67053e3); Vector3D r2 = new Vector3D(-3.41458e4, 2.05328e4, 3.44315e3); Vector3D r1_site = new Vector3D(4.72599e3, 1.26633e3, 4.07799e3); Vector3D r2_site = new Vector3D(4.70819e3, 1.33099e3, 4.07799e3); // get the topocentric positions Vector3D top1 = Transform.geo2radec(r1.scalarMultiply(1000), r1_site.scalarMultiply(1000)); Vector3D top2 = Transform.geo2radec(r2.scalarMultiply(1000), r2_site.scalarMultiply(1000)); // time of flight in seconds double tof = 3 * 3600; // propagate to 0 and tof Lambert test = new Lambert(); boolean cw = false; int multi_revs = 1; RealMatrix v1_mat; Random randomGenerator = new Random(); PrintWriter out_a = new PrintWriter("out_java_a.txt"); PrintWriter out_e = new PrintWriter("out_java_e.txt"); PrintWriter out_rho1 = new PrintWriter("out_java_rho1.txt"); PrintWriter out_rho2 = new PrintWriter("out_java_rho2.txt"); // start the loop double A, Ecc, rho1, rho2, tof_hyp; long time1 = System.nanoTime(); for (int ll = 0; ll < 1e6; ll++) { rho1 = top1.getZ() / 1000 + 1e-3 * randomGenerator.nextGaussian() * top1.getZ() / 1000; rho2 = top2.getZ() / 1000 + 1e-3 * randomGenerator.nextGaussian() * top2.getZ() / 1000; //tof_hyp = FastMath.abs(tof + 0.1*3600 * randomGenerator.nextGaussian()); // from topo to geo Vector3D r1_hyp = Transform.radec2geo(top1.getX(), top1.getY(), rho1, r1_site); Vector3D r2_hyp = Transform.radec2geo(top2.getX(), top2.getY(), rho2, r2_site); // System.out.println(r1_hyp.scalarMultiply(1000).getNorm()); // System.out.println(r2_hyp.scalarMultiply(1000).getNorm()); // System.out.println(tof/3600); test.lambert_problem(r1_hyp.scalarMultiply(1000), r2_hyp.scalarMultiply(1000), tof, mu, cw, multi_revs); v1_mat = test.get_v1(); Vector3D v1 = new Vector3D(v1_mat.getEntry(0, 0), v1_mat.getEntry(0, 1), v1_mat.getEntry(0, 2)); // System.out.println(v1); PVCoordinates rv1 = new PVCoordinates(r1_hyp.scalarMultiply(1000), v1); Orbit orbit_out = new KeplerianOrbit(rv1, inertialFrame, initialDate, mu); A = orbit_out.getA(); Ecc = orbit_out.getE(); // System.out.println(ll + " - " +A); out_a.println(A); out_e.println(Ecc); out_rho1.println(rho1); out_rho2.println(rho2); } long time2 = System.nanoTime(); long timeTaken = time2 - time1; out_a.close(); out_e.close(); out_rho1.close(); out_rho2.close(); System.out.println("Time taken " + timeTaken / 1000 / 1000 + " milli secs"); // get the truth test.lambert_problem(r1.scalarMultiply(1000), r2.scalarMultiply(1000), tof, mu, cw, multi_revs); v1_mat = test.get_v1(); Vector3D v1 = new Vector3D(v1_mat.getEntry(0, 0), v1_mat.getEntry(0, 1), v1_mat.getEntry(0, 2)); PVCoordinates rv1 = new PVCoordinates(r1.scalarMultiply(1000), v1); Orbit orbit_out = new KeplerianOrbit(rv1, inertialFrame, initialDate, mu); //System.out.println(orbit_out.getA()); } catch (FileNotFoundException ex) { Logger.getLogger(LambertMRev.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:fr.amap.lidar.amapvox.commons.GTheta.java
public static void main(String[] args) { LeafAngleDistribution distribution = new LeafAngleDistribution(LeafAngleDistribution.Type.EXTREMOPHILE); GTheta dirTrans = new GTheta(distribution); //dirTrans.buildTable(180); double densityProbability = dirTrans.getGThetaFromAngle(Math.toRadians(0), false); double densityProbability2 = dirTrans.getGThetaFromAngle(Math.toRadians(180), false); System.out.println("test"); }