List of usage examples for java.lang Math toDegrees
public static double toDegrees(double angrad)
From source file:Main.java
public static double getAbsAngle(double y, double x) { double angle = 0.0F; // atan2 is positive in the lower right quadrant and negative in upper right quadrant and measured // from the horizontal (positive x-axis) angle = Math.IEEEremainder(360 + Math.toDegrees(Math.atan2(y, x)), 360); return angle; }
From source file:Main.java
/** * Calculate the difference between true solar time and mean. The "equation * of time" is a term accounting for changes in the time of solar noon for * a given location over the course of a year. Earth's elliptical orbit and * Kepler's law of equal areas in equal times are the culprits behind this * phenomenon. See the//from w ww .java 2s . c o m * <A HREF="http://www.analemma.com/Pages/framesPage.html">Analemma page</A>. * Below is a plot of the equation of time versus the day of the year. * * <P align="center"><img src="doc-files/EquationOfTime.png"></P> * * @param t number of Julian centuries since J2000. * @return Equation of time in minutes of time. */ private static double equationOfTime(final double t) { double eps = Math.toRadians(obliquityCorrected(t)); double l0 = Math.toRadians(sunGeometricMeanLongitude(t)); double m = Math.toRadians(sunGeometricMeanAnomaly(t)); double e = eccentricityEarthOrbit(t); double y = Math.tan(eps / 2); y *= y; double sin2l0 = Math.sin(2 * l0); double cos2l0 = Math.cos(2 * l0); double sin4l0 = Math.sin(4 * l0); double sin1m = Math.sin(m); double sin2m = Math.sin(2 * m); double etime = y * sin2l0 - 2 * e * sin1m + 4 * e * y * sin1m * cos2l0 - 0.5 * y * y * sin4l0 - 1.25 * e * e * sin2m; return Math.toDegrees(etime) * 4.0; }
From source file:Main.java
/** * Converts an angle in radians to degrees *//*from w ww. j a v a2s . c om*/ public static double radToBearing(double rad) { return (Math.toDegrees(rad) + 360) % 360; }
From source file:Main.java
/** * Waypoint projection using haversine formula * http://en.wikipedia.org/wiki/Haversine_formula See discussion here for * further information: http://www.movable-type.co.uk/scripts/latlong.html *//*from ww w . j av a 2 s.c o m*/ public static double[] project(double distance, double bearing, double startLat, double startLon) { double distanceRad = distance / EARTH_RADIUS_KM; double bearingRad = Math.toRadians(bearing); double startLatRad = Math.toRadians(startLat); double startLonRad = Math.toRadians(startLon); double endLat = Math.asin(Math.sin(startLatRad) * Math.cos(distanceRad) + Math.cos(startLatRad) * Math.sin(distanceRad) * Math.cos(bearingRad)); double endLon = startLonRad + Math.atan2(Math.sin(bearingRad) * Math.sin(distanceRad) * Math.cos(startLatRad), Math.cos(distanceRad) - Math.sin(startLatRad) * Math.sin(endLat)); // Adjust projections crossing the 180th meridian: double endLonDeg = Math.toDegrees(endLon); if (endLonDeg > 180 || endLonDeg < -180) { endLonDeg = endLonDeg % 360; // Just in case we circle the earth // more than once. if (endLonDeg > 180) { endLonDeg = endLonDeg - 360; } else if (endLonDeg < -180) { endLonDeg = endLonDeg + 360; } } double[] endCoords = new double[] { Math.toDegrees(endLat), endLonDeg }; return endCoords; }
From source file:Main.java
/** * Gets the relative bearing from one geographical coordinate to another. * * @param latitude1 the latitude of the source point * @param longitude1 the longitude of the source point * @param latitude2 the latitude of the destination point * @param longitude2 the longitude of the destination point * @return the relative bearing from point 1 to point 2, in degrees. The result is guaranteed * to fall in the range 0-360/*from ww w . ja va2 s.c o m*/ */ public static float getBearing(double latitude1, double longitude1, double latitude2, double longitude2) { latitude1 = Math.toRadians(latitude1); longitude1 = Math.toRadians(longitude1); latitude2 = Math.toRadians(latitude2); longitude2 = Math.toRadians(longitude2); double dLon = longitude2 - longitude1; double y = Math.sin(dLon) * Math.cos(latitude2); double x = Math.cos(latitude1) * Math.sin(latitude2) - Math.sin(latitude1) * Math.cos(latitude2) * Math.cos(dLon); double bearing = Math.atan2(y, x); return mod((float) Math.toDegrees(bearing), 360.0f); }
From source file:org.gearvrf.keyboard.util.Util.java
public static float getXRotationAngle(GVRSceneObject rotatingObject, GVRSceneObject targetObject) { float angle = (float) Math.toDegrees(Math.atan2( targetObject.getTransform().getPositionY() - rotatingObject.getTransform().getPositionY(), targetObject.getTransform().getPositionZ() - rotatingObject.getTransform().getPositionZ())); if (rotatingObject.getTransform().getPositionZ() < 0) { if (rotatingObject.getTransform().getPositionY() > 10) { angle = angle + 90;//w w w . j a v a 2 s . c o m } else if (rotatingObject.getTransform().getPositionY() < 0) { angle = angle - 90; } } else { angle = angle - 180; } return angle; }
From source file:IK.G.java
public static double degrees(double in) { return Math.toDegrees(in); }
From source file:org.gearvrf.controls.util.MathUtils.java
public static float getYRotationAngle(GVRSceneObject rotatingObject, GVRSceneObject targetObject) { return (float) Math.toDegrees(Math.atan2( targetObject.getTransform().getPositionX() - rotatingObject.getTransform().getPositionX(), targetObject.getTransform().getPositionZ() - rotatingObject.getTransform().getPositionZ())); }
From source file:org.apache.hadoop.hive.ql.udf.UDFDegrees.java
public DoubleWritable evaluate(DoubleWritable i) { if (i == null) { return null; } else {//from w ww .ja v a2s. c om result.set(Math.toDegrees(i.get())); return result; } }
From source file:org.hbird.business.navigation.processors.orekit.AzimuthCalculator.java
@Override public void calculate(SpacecraftState startState, SpacecraftState endState, TopocentricFrame locationOnEarth, Frame inertialFrame, LocationContactEvent event) throws OrekitException { double startAzimuth = calculateAzimuth(startState, locationOnEarth, inertialFrame); double endAzimuth = calculateAzimuth(endState, locationOnEarth, inertialFrame); ContactParameterRange result = new ContactParameterRange(Math.toDegrees(startAzimuth), Math.toDegrees(endAzimuth)); event.setAzimuth(result);//from w w w. j a va 2 s .c o m }