Example usage for java.lang Math toDegrees

List of usage examples for java.lang Math toDegrees

Introduction

In this page you can find the example usage for java.lang Math toDegrees.

Prototype

public static double toDegrees(double angrad) 

Source Link

Document

Converts an angle measured in radians to an approximately equivalent angle measured in degrees.

Usage

From source file:org.apache.calcite.runtime.SqlFunctions.java

/** SQL <code>DEGREES</code> operator applied to long values. */
public static double degrees(long b0) {
    return Math.toDegrees(b0);
}

From source file:org.apache.calcite.runtime.SqlFunctions.java

/** SQL <code>DEGREES</code> operator applied to BigDecimal values. */
public static double degrees(BigDecimal b0) {
    return Math.toDegrees(b0.doubleValue());
}

From source file:org.apache.calcite.runtime.SqlFunctions.java

/** SQL <code>DEGREES</code> operator applied to double values. */
public static double degrees(double b0) {
    return Math.toDegrees(b0);
}

From source file:com.woofy.haifa.MapActivity.java

@Override
public void onSensorChanged(SensorEvent event) {
    if (event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR && rotation_on) {
        SensorManager.getRotationMatrixFromVector(mRotationMatrix, event.values);
        float[] orientation = new float[3];
        SensorManager.getOrientation(mRotationMatrix, orientation);
        bearing = (float) (Math.toDegrees(orientation[0]) + mDeclination);
        //              updateCamera(bearing);  TODO

    }/*from  w w  w.ja v  a  2  s .  co  m*/
}

From source file:radu.pidroid.Controller.java

@Override
public void onMove(JoystickView view, double x, double y) {
    int newX = ((int) (x * 101)) / 20 * 20;
    int newY = ((int) (y * 101)) / 20 * -20;

    switch (view.getId()) {

    case R.id.cameraJoystickView:
    case R.id.largeCameraJoystickView:
        // If any of the pan/tilt positions have changed, tell PiDroid about it.
        if (cameraX != newX || cameraY != newY) {
            cameraX = newX;/*from www. ja va  2s  .  c  om*/
            cameraY = newY;
            mMessenger.updateCameraPosition(cameraX, cameraY);
            Log.d("Controller: onMove():", "cameraX = " + cameraX + ", cameraY = " + cameraY);
        } // if
        break;

    case R.id.directionJoystickView:
        // If there is a new roverSpeed, tell PiDroid about it.
        if (roverSpeed != newY) {
            roverSpeed = newY;
            mMessenger.updateRoverSpeed(roverSpeed);
            //Log.d("Controller: onMove():", "roverSpeed = " + roverSpeed);
        } // if

        // Compute the angle made by the joystick measured with respect to the trigonometric circle.
        if (newX > 0)
            newX = (int) (Math.toDegrees(Math.atan(Math.abs((double) newY / newX))));
        else
            newX = (int) (Math.toDegrees(Math.atan(Math.abs((double) newX / newY))) + 90);

        // If there is a new turnAngle (or turning angle), tell PiDroid about it.
        if (turnAngle != newX) {
            turnAngle = newX;
            //Log.d("Controller: onMove():", "turn angle = " + turnAngle);
            mMessenger.updateRoverSpeed(roverSpeed);
        } // if
        break;
    } // switch
}

From source file:jp.furplag.util.commons.NumberUtils.java

/**
 * {@link java.lang.Math#toDegrees(double)}.
 *
 * @param radians/*w  w  w.  ja  v a  2  s . c o m*/
 * @return the angle represented by specified radian.
 */
public static double toDegrees(final Number radians) {
    if (Float.class.equals(NumberObject.of(radians).wrapper))
        return Math.toDegrees(valueOf(radians, float.class));

    return valueOf(radians, double.class) * 180d / Math.PI;
}

From source file:com.google.location.lbs.gnss.gps.pseudorange.UserPositionVelocityWeightedLeastSquare.java

/** Calculates the Gps tropospheric correction in meters */
private double calculateTroposphericCorrectionMeters(int dayOfYear1To366,
        double[][] satellitesPositionsECEFMeters, double[] userPositionTempECEFMeters, int satsCounter) {
    double troposphericCorrectionMeters;
    TopocentricAEDValues elevationAzimuthDist = EcefToTopocentricConverter
            .convertCartesianToTopocentericRadMeters(userPositionTempECEFMeters,
                    GpsMathOperations.subtractTwoVectors(satellitesPositionsECEFMeters[satsCounter],
                            userPositionTempECEFMeters));

    GeodeticLlaValues lla = Ecef2LlaConverter.convertECEFToLLACloseForm(userPositionTempECEFMeters[0],
            userPositionTempECEFMeters[1], userPositionTempECEFMeters[2]);

    // Geoid of the area where the receiver is located is calculated once and used for the
    // rest of the dataset as it change very slowly over wide area. This to save the delay
    // associated with accessing Google Elevation API. We assume this very first iteration of WLS
    // will compute the correct altitude above the ellipsoid of the ground at the latitude and
    // longitude/*from w ww.j a  v a  2s  .c  om*/
    if (calculateGeoidMeters) {
        double elevationAboveSeaLevelMeters = 0;
        if (elevationApiHelper == null) {
            System.out.println("No Google API key is set. Elevation above sea level is set to "
                    + "default 0 meters. This may cause inaccuracy in tropospheric correction.");
        } else {
            try {
                elevationAboveSeaLevelMeters = elevationApiHelper.getElevationAboveSeaLevelMeters(
                        Math.toDegrees(lla.latitudeRadians), Math.toDegrees(lla.longitudeRadians));
            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("Error when getting elevation from Google Server. "
                        + "Could be wrong Api key or network error. Elevation above sea level is set to "
                        + "default 0 meters. This may cause inaccuracy in tropospheric correction.");
            }
        }

        geoidHeightMeters = ElevationApiHelper.calculateGeoidHeightMeters(lla.altitudeMeters,
                elevationAboveSeaLevelMeters);
        troposphericCorrectionMeters = TroposphericModelEgnos.calculateTropoCorrectionMeters(
                elevationAzimuthDist.elevationRadians, lla.latitudeRadians, elevationAboveSeaLevelMeters,
                dayOfYear1To366);
    } else {
        troposphericCorrectionMeters = TroposphericModelEgnos.calculateTropoCorrectionMeters(
                elevationAzimuthDist.elevationRadians, lla.latitudeRadians,
                lla.altitudeMeters - geoidHeightMeters, dayOfYear1To366);
    }
    return troposphericCorrectionMeters;
}

From source file:uk.ac.diamond.scisoft.analysis.diffraction.PowderRingsUtils.java

/**
 * Create function which uses 6N+1 parameters: wavelength (Angstrom), and per image, detector origin (mm), orientation angles (degrees)
 *///from  www  .java  2 s . c  o m
static DetectorFitFunction createQFitFunctionForAllImages(List<List<EllipticalROI>> lEllipses,
        List<DetectorProperties> lDP, double wavelength) {
    int m = lEllipses.size();
    if (lDP.size() != m) {
        throw new IllegalArgumentException(
                "Number of lists of ellipses should be equal to number of detectors");
    }

    double[][][] allKnowns = new double[m][][];
    double[][] allWeights = new double[m][];
    double[] bases = new double[m];
    double[] init = new double[6 * m + 1];

    int l = 0;
    init[l++] = wavelength;
    for (int k = 0; k < m; k++) {
        List<EllipticalROI> ellipses = lEllipses.get(k);
        DetectorProperties dp = lDP.get(k);
        double dist = dp.getBeamCentreDistance();
        int n = ellipses.size();
        double[][] known = new double[n][FitFunctionBase.nC];
        allKnowns[k] = known;
        double[] weight = new double[n];
        allWeights[k] = weight;

        double base = -calcBaseRollAngle(ellipses);
        bases[k] = base;
        logger.debug("Mean roll angle: {}", Math.toDegrees(base));

        for (int i = 0; i < n; i++) {
            EllipticalROI e = ellipses.get(i);
            weight[i] = e.getSemiAxis(0) / dist;
            int j = 0;
            double a = base - e.getAngle();
            for (double off : FitFunctionBase.angles) {
                double[] pt = e.getPoint(a + off);
                known[i][j++] = pt[0];
                known[i][j++] = pt[1];
            }
        }
        Vector3d o = dp.getOrigin();
        init[l++] = o.getX();
        init[l++] = o.getY();
        init[l++] = o.getZ();
        double[] a = dp.getNormalAnglesInDegrees();
        init[l++] = a[0];
        init[l++] = a[1];
        init[l++] = a[2];
    }

    DetectorFitFunction f = new QSpacesFitFunction(allKnowns, allWeights, lDP.get(0).getVPxSize());
    f.setInitial(init);
    f.setBaseRollAngles(bases);
    return f;
}

From source file:lapidus.edu.rec3dclient.camera.Camera2BasicFragment.java

private void updateText() {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < vOrientation.length; i++) {
        sb.append(String.format("%.2f", Math.toDegrees(vOrientation[i]))).append(" : ");
    }//from  ww  w.ja  v  a  2  s.  co m
    coordsView.setText(sb);
}

From source file:de.erdesignerng.visual.jgraph.JGraphEditor.java

private void performRadialLayout() {

    Model theModel = graph.getDBModel();

    List<Set<Table>> theLayers = buildHierarchy(theModel);

    int centerx = 500 * (theLayers.size() + 1);
    int centery = 500 * (theLayers.size() + 1);
    int theRadius = 0;
    for (int theLayer = theLayers.size() - 1; theLayer >= 0; theLayer--) {
        Set<Table> theLayerTables = theLayers.get(theLayer);
        if (theLayerTables.size() > 0) {

            TableCellView.MyRenderer theRenderer = new TableCellView.MyRenderer();
            double thePerimeter = 0;
            double theMinRadius = 0;
            for (Table theTable : theLayerTables) {
                JComponent theRendererComponent = theRenderer.getRendererComponent(theTable);
                Dimension theSize = theRendererComponent.getPreferredSize();
                double theR = Math.sqrt(theSize.width * theSize.width + theSize.height * theSize.height);
                thePerimeter += theR;//  www . j a  v  a2s.c o m

                theMinRadius = Math.max(theMinRadius, theR);
            }
            thePerimeter += theLayerTables.size() * 40;

            double theRadiusIncrement = (thePerimeter / (Math.PI * 2)) - theRadius;
            theRadius += Math.max(theRadiusIncrement, theMinRadius);

            double theIncrement = Math.toDegrees(360 / theLayerTables.size());
            double theAngle = 0;

            for (Table theTable : theLayerTables) {
                int theXP = centerx + (int) (Math.cos(theAngle) * theRadius);
                int theYP = centery + (int) (Math.sin(theAngle) * theRadius);
                theTable.getProperties().setPointProperty(Table.PROPERTY_LOCATION, theXP, theYP);
                theAngle += theIncrement;
            }
            theRadius += 500;
        }
    }

    if (theModel.getViews().size() > 0) {
        double theIncrement = Math.toDegrees(360 / theModel.getViews().size());
        double theAngle = 0;
        for (View theView : theModel.getViews()) {
            int theXP = centerx + (int) (Math.cos(theAngle) * theRadius);
            int theYP = centery + (int) (Math.sin(theAngle) * theRadius);
            theView.getProperties().setPointProperty(View.PROPERTY_LOCATION, theXP, theYP);
            theAngle += theIncrement;
        }
    }

    updatePositions();

    repaintGraph();
}