List of usage examples for java.lang Math toDegrees
public static double toDegrees(double angrad)
From source file:org.gearvrf.controls.util.MathUtils.java
public static float getYRotationAngle(GVRSceneObject rotatingObject, GVRCameraRig targetObject) { return (float) Math.toDegrees(Math.atan2( targetObject.getTransform().getPositionX() - rotatingObject.getTransform().getPositionX(), targetObject.getTransform().getPositionZ() - rotatingObject.getTransform().getPositionZ())); }
From source file:eu.itesla_project.iidm.ddb.eurostag.model.TransformerModel.java
public StateVariable toSv2(StateVariable sv1) { Complex s1 = new Complex(-sv1.p, -sv1.q); // s1=p1+jq1 Complex u1 = ComplexUtils.polar2Complex(sv1.u, Math.toRadians(sv1.theta)); Complex v1 = u1.divide(SQUARE_3); // v1=u1/sqrt(3) Complex v1p = v1.multiply(ratio); // v1p=v1*rho Complex i1 = s1.divide(v1.multiply(3)).conjugate(); // i1=conj(s1/(3*v1)) Complex i1p = i1.divide(ratio); // i1p=i1/rho Complex i2 = i1p.subtract(y.multiply(v1p)).negate(); // i2=-(i1p-y*v1p) Complex v2 = v1p.subtract(z.multiply(i2)); // v2=v1p-z*i2 Complex s2 = v2.multiply(3).multiply(i2.conjugate()); // s2=3*v2*conj(i2) Complex u2 = v2.multiply(SQUARE_3);//from w w w.j ava2 s .com return new StateVariable(-s2.getReal(), -s2.getImaginary(), u2.abs(), Math.toDegrees(u2.getArgument())); }
From source file:eu.betaas.taas.securitymanager.taastrustmanager.taastrustcalculator.ScalabilityCalculator.java
public float calculateTrustAspect(String thingServiceId) { // Check enough data is available if (tsData.length < 4) { logger.error("Not enough data is available -> Returning default value."); return 2.0f; }//from w w w . j a v a 2 s . com // 1 - Scalability of memory in time // 1.1 - Calculate slope of the line generated with linear regression float slope = linearRegressionSlope(tsData); logger.debug("Memory usage slope: " + slope); // 1.2 - Calculate the angle corresponding to the slope double angle = Math.toDegrees(Math.atan(slope)); logger.debug("Memory usage angle: " + angle); // 1.3 - Determine trust value for that angle float memoryTrust = 2.5f; if (angle <= 0.0) { memoryTrust = 4.8f; } else if (angle > 65.0) { memoryTrust = 0.05f; } else { memoryTrust = ((66.0f - (float) angle) * 4.5f) / 66.0f; } logger.debug("Memory Trust: " + memoryTrust); // 2 - Scalability of response time as requests grow return memoryTrust; }
From source file:com.cloudmade.api.Utils.java
/** * Convert tile coordinates pair to latitude, longitude * /*from w w w . ja v a2s .c o m*/ * @param xtile * @param ytile * @param zoom * @return Latitude, longitude pair */ public static final double[] tilenums2latlon(int xtile, int ytile, int zoom) { double factor = 1 << zoom; double latitude = Math.atan(Math.sinh(Math.PI * (1 - 2 * ytile / factor))); double longitude = (xtile * 360.0 / factor) - 180.0; return new double[] { Math.toDegrees(latitude), longitude }; }
From source file:edu.ucsf.valelab.saim.calculations.TestSaimCalc.java
public void test() throws Exception { final double wl = 525.0; final double nSample = 1.33; // Phase difference double phaseDiff = SaimCalc.PhaseDiff(wl, Math.toRadians(0.0), nSample, 0.0); System.out.println("Phase difference: " + phaseDiff); assertEquals(0.0, phaseDiff, 0.00000000001); phaseDiff = SaimCalc.PhaseDiff(wl, Math.toRadians(0.0), nSample, 100.0); assertEquals(3.1834805556376575, phaseDiff, 0.00000000001); System.out.println("Phase difference: " + phaseDiff); phaseDiff = SaimCalc.PhaseDiff(wl, Math.toRadians(0.0), nSample, 200.0); System.out.println("Phase difference: " + phaseDiff); assertEquals(6.366961111275315, phaseDiff, 0.00000000001); // Snell's law calculations // air to water at 30 degrees double angle = Math.toDegrees(SaimCalc.snell2(Math.toRadians(30.0), 1.0, 1.33)); System.out.println("Angle found was " + angle + " degrees"); assertEquals(22.082413194472252, angle, 0.0000001); // angular wavenumber calculation // wavenumber in oil for 488nm light double k = SaimCalc.k(488.0, 1.55); System.out.println("Wavenumber in oil at 488nm: " + k); assertEquals(0.019956838578131884, k, 0.0000001); // TODO: check that these Fresnel Coefficients are actually correct! Complex fc1 = SaimCalc.fresnelTE(wl, Math.toRadians(0.0), wl, nSample); System.out.println("Fresnel Coeficient: " + fc1.toString()); assertEquals(-0.46513448826603965, fc1.getReal(), 0.00000000001); assertEquals(0.2175327339364143, fc1.getImaginary(), 0.00000000001); fc1 = SaimCalc.fresnelTE(wl, Math.toRadians(10.0), wl, nSample); System.out.println("Fresnel Coeficient: " + fc1.toString()); assertEquals(-0.410993277015784, fc1.getReal(), 0.00000000001); assertEquals(0.30908357106454865, fc1.getImaginary(), 0.00000000001); }
From source file:controller.JsonController.java
public ArrayList<JsonModel> ReadJsonCalc() throws FileNotFoundException, IOException, ParseException { FileInputStream fstream = new FileInputStream("gistfile1.txt"); BufferedReader br = new BufferedReader(new InputStreamReader(fstream)); String strLine;/* w w w .j a v a 2 s. c o m*/ ArrayList<JsonModel> result = new ArrayList<>(); JsonModel model; double L1, G1, L2, G2; //Read File Line By Line while ((strLine = br.readLine()) != null) { model = new JsonModel(); JSONParser parser = new JSONParser(); Object obj = parser.parse(strLine); JSONObject jsonObject = (JSONObject) obj; model.setLatitude((double) Double.parseDouble((String) jsonObject.get("latitude"))); model.setLongitude((double) Double.parseDouble((String) jsonObject.get("longitude"))); model.setUserIid((int) Integer.parseInt((String) jsonObject.get("user_id").toString())); model.setName(((String) jsonObject.get("name"))); L1 = Math.toRadians(model.getLatitudeDefault()); G1 = Math.toRadians(model.getLongitudeDefault()); L2 = Math.toRadians(model.getLatitude()); G2 = Math.toRadians(model.getLongitude()); // do the spherical trig calculation double angle = Math.acos(Math.sin(L1) * Math.sin(L2) + Math.cos(L1) * Math.cos(L2) * Math.cos(G1 - G2)); // convert back to degrees angle = Math.toDegrees(angle); // each degree on a great circle of Earth is 69.1105 miles double distance = (69.1105 * angle) * 1.609344; if (distance <= 100) result.add(model); } Collections.sort(result); return result; }
From source file:magma.agent.perception.impl.VisibleObjectPerceptor.java
@Override public double getHorizontalAngleDeg() { return Math.toDegrees(position.getAlpha()); }
From source file:edu.mit.fss.tutorial.part2.MobileElement.java
@Override public double getLatitude() { return Math.toDegrees(Math.atan2(position.getZ(), position.getX())); }
From source file:demo.support.NavUtils.java
/** * Returns bearing of position 2 from position 1. * @param pt1/*w w w. ja v a 2 s . co m*/ * @param pt2 * @return */ public static double getBearing(Point pt1, Point pt2) { double longitude1 = pt1.getLongitude(); double longitude2 = pt2.getLongitude(); double latitude1 = Math.toRadians(pt1.getLatitude()); double latitude2 = Math.toRadians(pt2.getLatitude()); double longDiff = Math.toRadians(longitude2 - longitude1); double y = Math.sin(longDiff) * Math.cos(latitude2); double x = Math.cos(latitude1) * Math.sin(latitude2) - Math.sin(latitude1) * Math.cos(latitude2) * Math.cos(longDiff); return (Math.toDegrees(Math.atan2(y, x)) + 360) % 360; }
From source file:edu.csun.ecs.cs.multitouchj.ui.utility.PointUtility.java
public static float getAngle(Point point, boolean isCartesianCoordinateSystem) { Point targetPoint = new Point(point); if (!isCartesianCoordinateSystem) { targetPoint.setY((-1 * targetPoint.getY())); }//from w w w.j a v a 2 s. c om Point origin = new Point(0.0f, 0.0f); float distance = PointUtility.getDistance(origin, targetPoint); float deltaX = Math.abs(targetPoint.getX()); float angle = (float) Math.toDegrees(Math.acos((deltaX / distance))); if (targetPoint.getX() > 0.0f) { if (targetPoint.getY() > 0.0f) { // nothing to do } else { angle = (360.0f - angle); } } else { if (targetPoint.getY() > 0.0f) { angle = (180.0f - angle); } else { angle = (180.0f + angle); } } return angle; }