List of usage examples for java.lang Math toRadians
public static double toRadians(double angdeg)
From source file:ca.sqlpower.wabit.swingui.chart.ChartSwingUtil.java
/** * Creates a JFreeChart based on the current query results produced by the * given chart.//from w w w . j a va 2 s. c o m * * @param c * The chart from which to produce a JFreeChart component. Must * not be null. * @return A chart based on the data and settings in the given chart, or * null if the given chart is not sufficiently configured (for * example, if its type is not set) or it is currently unable to * produce a result set. */ public static JFreeChart createChartFromQuery(Chart c) throws SQLException, QueryInitializationException, InterruptedException { logger.debug("Creating JFreeChart for Wabit chart " + c); ChartType chartType = c.getType(); if (chartType == null) { logger.debug("Returning null (chart's type is not set)"); return null; } final JFreeChart chart; if (chartType.getDatasetType().equals(DatasetType.CATEGORY)) { JFreeChart categoryChart = createCategoryChart(c); logger.debug("Made a new category chart: " + categoryChart); if (categoryChart != null && categoryChart.getPlot() instanceof CategoryPlot) { double rotationRads = Math.toRadians(c.getXAxisLabelRotation()); CategoryLabelPositions clp; if (Math.abs(rotationRads) < 0.05) { clp = CategoryLabelPositions.STANDARD; } else if (rotationRads < 0) { clp = CategoryLabelPositions.createUpRotationLabelPositions(-rotationRads); } else { clp = CategoryLabelPositions.createDownRotationLabelPositions(rotationRads); } CategoryAxis domainAxis = categoryChart.getCategoryPlot().getDomainAxis(); domainAxis.setMaximumCategoryLabelLines(5); domainAxis.setCategoryLabelPositions(clp); } chart = categoryChart; } else if (chartType.getDatasetType().equals(DatasetType.XY)) { JFreeChart xyChart = createXYChart(c); logger.debug("Made a new XY chart: " + xyChart); chart = xyChart; } else { throw new IllegalStateException("Unknown chart dataset type " + chartType.getDatasetType()); } if (chart != null) { makeChartNice(chart); } return chart; }
From source file:magma.agent.behavior.complex.MoveWithBall.java
private boolean checkAngle(double angle) { return equals(thisPlayer.getHorizontalAngle(), Angle.deg(zAngle), Math.toRadians(10)) || equals(thisPlayer.getHorizontalAngle(), Angle.deg(-zAngle), Math.toRadians(10)); }
From source file:org.immopoly.appengine.actions.ActionUserAction.java
public static double calcDistance(double lat1, double lng1, double lat2, double lng2) { double earthRadius = 3958.75; double dLat = Math.toRadians(lat2 - lat1); double dLng = Math.toRadians(lng2 - lng1); double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * Math.sin(dLng / 2) * Math.sin(dLng / 2); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); double dist = earthRadius * c; int meterConversion = 1609; return new Double(dist * meterConversion).doubleValue(); }
From source file:com.laex.cg2d.model.joints.BERevoluteJoint.java
@Override public void setPropertyValue(Object id, Object value) { if (isReferenceAngleProp(id)) { revoluteJointDef.referenceAngle = (float) Math.toRadians(FloatUtil.toFloat(value)); } else if (isEnableLimitProp(id)) { revoluteJointDef.enableLimit = BooleanUtil.toBool(value); } else if (isLowerAngleProp(id)) { revoluteJointDef.lowerAngle = FloatUtil.toFloat(value); } else if (isUpperAngleProp(id)) { revoluteJointDef.upperAngle = FloatUtil.toFloat(value); } else if (isEnableMotorProp(id)) { revoluteJointDef.enableMotor = BooleanUtil.toBool(value); } else if (isMotorSpeedProp(id)) { revoluteJointDef.motorSpeed = FloatUtil.toFloat(value); } else if (isMaxMotorTorqueProp(id)) { revoluteJointDef.maxMotorTorque = FloatUtil.toFloat(value); } else {// w ww.j ava 2 s . c om super.setPropertyValue(id, value); } }
From source file:com.duy.pascal.interperter.libraries.math.MathLib.java
@PascalMethod(description = "") public double CycleToRad(double cycle) { double degree = cycle * 360; return Math.toRadians(degree); }
From source file:com.nanosheep.bikeroute.parser.GoogleElevationParser.java
/** * Calculate the distance between two points of the earth using * the haversine formula./*from w w w.j a va 2 s. c o m*/ * @param lat Starting latitude. * @param lng Starting longitude. * @param latA End latitude, * @param lngA End longitude. * @return The distance between the two points in m. */ private double pointDiff(final double lat, final double lng, final double latA, final double lngA) { final double dLat = Math.toRadians(latA - lat); final double dLon = Math.toRadians(lngA - lng); final double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(Math.toRadians(lat)) * Math.cos(Math.toRadians(latA)) * Math.sin(dLon / 2) * Math.sin(dLon / 2); final double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); return BikeRouteConsts.EARTH_RADIUS * c * 1000; }
From source file:com.esri.geoevent.solutions.processor.ellipse.EllipseProcessor.java
@Override public GeoEvent process(GeoEvent ge) throws Exception { if (!ge.getGeoEventDefinition().getTagNames().contains("GEOMETRY")) { return null; }/*w ww . jav a2 s . c o m*/ inwkid = ge.getGeometry().getSpatialReference().getID(); if (majorAxisRadius.isNaN()) { majorAxisRadius = (Double) ge.getField(majorAxisField); } if (minorAxisRadius.isNaN()) { minorAxisRadius = (Double) ge.getField(minorAxisField); } if (rotation.isNaN()) { rotation = (Double) ge.getField(rotationField); } MapGeometry mapGeo = ge.getGeometry(); Geometry geo = mapGeo.getGeometry(); if (!(geo instanceof Point)) { return null; } Point eventGeo = (Point) geo; double x = eventGeo.getX(); double y = eventGeo.getY(); double rdeg = GeometryUtility.Geo2Arithmetic(rotation); double r = Math.toRadians(rdeg); MapGeometry ellipse = constructEllipse(x, y, majorAxisRadius, minorAxisRadius, r, inwkid, procwkid, outwkid); ge.setGeometry(ellipse); return ge; }
From source file:org.apache.flink.table.runtime.functions.SqlFunctionUtils.java
public static double radians(Decimal angdeg) { return Math.toRadians(angdeg.doubleValue()); }
From source file:io.github.malapert.jwcs.coordsystem.Utility.java
/** * Calculates the matrix that represents a 3d rotation around the Z axis. * //from w ww . j a v a 2 s. com * @param angle Rotation angle in degrees * @return A 3x3 matrix representing the rotation about angle around Z axis. */ public final static RealMatrix rotZ(double angle) { double angleRadians = Math.toRadians(angle); double[][] array = { { Math.cos(angleRadians), Math.sin(angleRadians), 0.d }, { -1 * Math.sin(angleRadians), Math.cos(angleRadians), 0.d }, { 0.d, 0.d, 1.d } }; return MatrixUtils.createRealMatrix(array); }
From source file:com.nuig.trafficapp.MyGcmListenerService.java
public static double distFrom(double lat1, double lng1, double lat2, double lng2) { double earthRadius = 6371; double dLat = Math.toRadians(lat2 - lat1); double dLng = Math.toRadians(lng2 - lng1); double sindLat = Math.sin(dLat / 2); double sindLng = Math.sin(dLng / 2); double a = Math.pow(sindLat, 2) + Math.pow(sindLng, 2) * Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); double dist = earthRadius * c; return dist;/* w w w . j a va2 s. c o m*/ }