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:eu.itesla_project.iidm.network.util.SV.java

public SV otherSide(float r, float x, float g, float b, float ratio) {
    Complex z = new Complex(r, x); // z=r+jx
    Complex y = new Complex(g, b); // y=g+jb
    Complex s1 = new Complex(p, q); // s1=p1+jq1
    Complex u1 = ComplexUtils.polar2Complex(u, Math.toRadians(a));
    Complex v1 = u1.divide(Math.sqrt(3f)); // 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)); // 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(Math.sqrt(3f));
    return new SV((float) -s2.getReal(), (float) -s2.getImaginary(), (float) u2.abs(),
            (float) Math.toDegrees(u2.getArgument()));
}

From source file:be.ugent.maf.cellmissy.analysis.singlecell.processing.impl.interpolation.InterpolatedTrackOperatorImpl.java

@Override
public void computeTurningAngles(InterpolatedTrack interpolatedTrack) {
    // get the (already computed) delta movements of the interpolated track
    double[][] deltaMovements = interpolatedTrack.getDeltaMovements();
    double[] turningAngles = new double[deltaMovements.length];
    for (int row = 0; row < turningAngles.length; row++) {
        // angle = degrees(atan(deltaY/deltaX))
        double angleRadians = Math.atan2(deltaMovements[row][0], deltaMovements[row][1]);
        // go from radians to degrees
        turningAngles[row] = Math.toDegrees(angleRadians);
    }/*from   w  w  w .jav  a2  s  . c o  m*/
    interpolatedTrack.setTurningAngles(turningAngles);
}

From source file:com.metinkale.prayerapp.compass._2D.Frag2D.java

@Override
public void onUpdateSensors(float[] rot) {
    if (mCompassView != null && getActivity() != null) {
        // mCompassView.setAngle(rot[0]);
        mGravity = LowPassFilter.filter(((Main) getActivity()).mMagAccel.mAccelVals, mGravity);
        mGeo = LowPassFilter.filter(((Main) getActivity()).mMagAccel.mMagVals, mGeo);

        if ((mGravity != null) && (mGeo != null)) {
            float[] R = new float[9];
            float[] I = new float[9];
            boolean success = SensorManager.getRotationMatrix(R, I, mGravity, mGeo);
            if (success) {
                float[] orientation = new float[3];
                SensorManager.getOrientation(R, orientation);

                mCompassView.setAngle((int) Math.toDegrees(orientation[0]));

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

}

From source file:org.jlab.clas.swimtools.Swim.java

/**
 * Sets the parameters used by swimmer based on the input track state vector
 * parameters swimming outwards//  www . jav  a2 s. co m
 *
 * @param superlayerIdx
 * @param layerIdx
 * @param x0
 * @param y0
 * @param thx
 * @param thy
 * @param p
 * @param charge
 */
public void SetSwimParameters(int superlayerIdx, int layerIdx, double x0, double y0, double z0, double thx,
        double thy, double p, int charge) {
    // z at a given DC plane in the tilted coordinate system
    // x,y,z in m = swimmer units
    _x0 = x0 / 100;
    _y0 = y0 / 100;
    _z0 = z0 / 100;
    this.checkR(_x0, _y0, _z0);
    double pz = p / Math.sqrt(thx * thx + thy * thy + 1);
    double px = thx * pz;
    double py = thy * pz;
    _phi = Math.toDegrees(FastMath.atan2(py, px));
    _pTot = Math.sqrt(px * px + py * py + pz * pz);
    _theta = Math.toDegrees(Math.acos(pz / _pTot));

    _charge = charge;

}

From source file:com.cyrilmottier.android.polaris2demo.CircleDemoActivity.java

/** Generate LatLng of radius marker */
private static LatLng toRadiusLatLng(LatLng center, double radius) {
    double radiusAngle = Math.toDegrees(radius / RADIUS_OF_EARTH_METERS)
            / Math.cos(Math.toRadians(center.latitude));
    return new LatLng(center.latitude, center.longitude + radiusAngle);
}

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

public static Dataset[] generateMinMaxAzimuthalArray(double[] beamCentre, int[] shape, double min) {
    //Number of circles
    int n = (int) Math.floor((min + 180) / 360);
    double minInBase = (min - (360 * n));
    Dataset aMax = DatasetFactory.zeros(shape, Dataset.FLOAT64);
    Dataset aMin = DatasetFactory.zeros(shape, Dataset.FLOAT64);

    PositionIterator iter = aMax.getPositionIterator();
    int[] pos = iter.getPos();
    double[] vals = new double[4];

    while (iter.hasNext()) {
        //find vals at pixel corners
        vals[0] = Math.toDegrees(Math.atan2(pos[0] - beamCentre[1], pos[1] - beamCentre[0]));
        vals[1] = Math.toDegrees(Math.atan2(pos[0] - beamCentre[1] + 1, pos[1] - beamCentre[0]));
        vals[2] = Math.toDegrees(Math.atan2(pos[0] - beamCentre[1], pos[1] - beamCentre[0] + 1));
        vals[3] = Math.toDegrees(Math.atan2(pos[0] - beamCentre[1] + 1, pos[1] - beamCentre[0] + 1));
        if (vals[0] < minInBase)
            vals[0] = vals[0] + 360;/*w  w  w. j a  v  a 2  s .  c  om*/
        if (vals[1] < minInBase)
            vals[1] = vals[1] + 360;
        if (vals[2] < minInBase)
            vals[2] = vals[2] + 360;
        if (vals[3] < minInBase)
            vals[3] = vals[3] + 360;

        Arrays.sort(vals);
        //if the pixel needs to be split over 180 degrees, over the discontinuity
        //Only split up to the discontinuity on the side with the largest range
        //Should only change the single row of pixels allow the discontinuity
        //         (vals[0] < -Math.PI/2 && vals[3] > Math.PI/2)

        if (vals[3] - vals[0] > 180) {
            //FIXME do best to handle discontinuity here - saves changing the integration routine
            //may not be as accurate - might need to make the integration aware.
            //currently just squeeze all the signal in one side

            if ((minInBase + 360) - vals[3] > vals[0] - minInBase) {
                vals[0] = vals[3];
                vals[3] = minInBase + 360;
            } else {
                vals[3] = vals[0];
                vals[0] = minInBase;

            }
        }

        aMax.set(vals[3] + 360 * n, pos);
        aMin.set(vals[0] + 360 * n, pos);

    }

    return new Dataset[] { aMin, aMax };
}

From source file:de.quist.app.maps.example.CircleDemoActivity.java

/** Generate LatLng of radius marker */
private static LatLng toRadiusLatLng(LatLng center, double radius) {
    double radiusAngle = Math.toDegrees(radius / RADIUS_OF_EARTH_METERS)
            / Math.cos(Math.toRadians(center.latitude()));
    return BuildConfig.MAP_BINDING.newLatLng(center.latitude(), center.longitude() + radiusAngle);
}

From source file:org.mapfish.print.map.readers.WMSMapReader.java

public void render(Transformer transformer, ParallelMapTileLoader parallelMapTileLoader, String srs,
        boolean first) {
    PJsonObject customParams = params.optJSONObject("customParams");

    // store the rotation to not change for other layers
    double oldAngle = transformer.getRotation();

    // native WMS rotation - only works in singleTile mode
    if (customParams != null && customParams.optString("angle") != null) { // For GeoServer
        transformer.setRotation(0);/*from   ww w .j a  v a2s . c  o  m*/
    }
    if (params.optBool("useNativeAngle", false)) {
        String angle = String.valueOf(-Math.toDegrees(transformer.getRotation()));
        try {
            if (customParams != null) {
                customParams.getInternalObj().put("angle", angle); // For GeoServer
                customParams.getInternalObj().put("map_angle", angle); // For MapServer
            } else {
                Map<String, String> customMap = new HashMap<String, String>();
                customMap.put("angle", angle); // For GeoServer
                customMap.put("map_angle", angle); // For MapServer
                params.getInternalObj().put("customParams", customMap);
            }
            transformer.setRotation(0);
        } catch (org.json.JSONException e) {
            LOGGER.error("Unable to set angle: " + e.getClass().getName() + " - " + e.getMessage());
        }
    }
    super.render(transformer, parallelMapTileLoader, srs, first);
    // restore the rotation for other layers
    transformer.setRotation(oldAngle);
}

From source file:org.opentripplanner.analyst.request.SampleGridRenderer.java

/**
 * @param spgRequest/*  ww w . j  av  a  2  s  . c  om*/
 * @param sptRequest
 * @return
 */
public ZSampleGrid<WTWD> getSampleGrid(SampleGridRequest spgRequest, RoutingRequest sptRequest) {

    final double D0 = getOffRoadDistanceMeters(spgRequest.precisionMeters);
    final double V0 = 1.00; // m/s, off-road walk speed

    // 1. Compute the Shortest Path Tree.
    long t0 = System.currentTimeMillis();
    long tOvershot = (long) (2 * D0 / V0);
    sptRequest.worstTime = (sptRequest.dateTime
            + (sptRequest.arriveBy ? -spgRequest.maxTimeSec - tOvershot : spgRequest.maxTimeSec + tOvershot));
    sptRequest.batch = (true);
    sptRequest.setRoutingContext(graphService.getGraph(sptRequest.routerId));
    final ShortestPathTree spt = sptService.getShortestPathTree(sptRequest);

    // 3. Create a sample grid based on the SPT.
    long t1 = System.currentTimeMillis();
    Coordinate coordinateOrigin = spgRequest.coordinateOrigin;
    if (coordinateOrigin == null)
        coordinateOrigin = sptRequest.from.getCoordinate();
    final double gridSizeMeters = spgRequest.precisionMeters;
    final double cosLat = FastMath.cos(toRadians(coordinateOrigin.y));
    double dY = Math.toDegrees(gridSizeMeters / SphericalDistanceLibrary.RADIUS_OF_EARTH_IN_M);
    double dX = dY / cosLat;

    SparseMatrixZSampleGrid<WTWD> sampleGrid = new SparseMatrixZSampleGrid<WTWD>(16, spt.getVertexCount(), dX,
            dY, coordinateOrigin);
    sampleSPT(spt, sampleGrid, gridSizeMeters * 0.7, gridSizeMeters, V0, sptRequest.getMaxWalkDistance(),
            cosLat);
    sptRequest.cleanup();

    long t2 = System.currentTimeMillis();
    LOG.info("Computed SPT in {}msec, {}msec for sampling ({} msec total)", (int) (t1 - t0), (int) (t2 - t1),
            (int) (t2 - t0));

    return sampleGrid;
}

From source file:org.netxilia.functions.MathFunctions.java

public double DEGREES(double number) {
    return Math.toDegrees(number);
}