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.solovyev.android.calculator.drag.SimpleDragListener.java

@Override
public boolean onDrag(@Nonnull DragButton dragButton, @Nonnull DragEvent event) {
    boolean consumed = false;

    final MotionEvent motionEvent = event.getMotionEvent();

    final Point2d start = event.getStartPoint();
    final Point2d end = new Point2d(motionEvent.getX(), motionEvent.getY());
    final float distance = Maths.getDistance(start, end);

    final MutableObject<Boolean> right = new MutableObject<>();
    final double angle = Math.toDegrees(Maths.getAngle(start, Maths.sum(start, axis), end, right));

    final long duration = motionEvent.getEventTime() - motionEvent.getDownTime();
    final DragDirection direction = getDirection(distance, (float) angle, right.getObject());
    if (direction != null && duration > 40 && duration < 2500) {
        consumed = processor.processDragEvent(direction, dragButton, start, motionEvent);
    }// w w w . ja va 2 s  .c om

    return consumed;
}

From source file:eu.itesla_project.iidm.ddb.eurostag.model.TransformerModel.java

public StateVariable toSv1(StateVariable sv2) {
    Complex s2 = new Complex(-sv2.p, -sv2.q); // s2=p2+jq2
    Complex u2 = ComplexUtils.polar2Complex(sv2.u, Math.toRadians(sv2.theta));
    Complex v2 = u2.divide(SQUARE_3); // v2=u2/sqrt(3)
    Complex i2 = s2.divide(v2.multiply(3)).conjugate(); // i2=conj(s2/(3*v2))
    Complex v1p = v2.add(z.multiply(i2)); // v1'=v2+z*i2
    Complex i1p = i2.negate().add(y.multiply(v1p)); // i1'=-i2+v1'*y
    Complex i1 = i1p.multiply(ratio); // i1=i1p*ration
    Complex v1 = v1p.divide(ratio); // v1=v1p/ration
    Complex s1 = v1.multiply(3).multiply(i1.conjugate()); // s1=3*v1*conj(i1)
    Complex u1 = v1.multiply(SQUARE_3);/*from w ww .  j av  a 2s  .  c  o m*/
    return new StateVariable(-s1.getReal(), -s1.getImaginary(), u1.abs(), Math.toDegrees(u1.getArgument()));
}

From source file:org.gearvrf.keyboard.util.Util.java

public static float getYRotationAngle(Vector3D rotatingVector, GVRSceneObject targetObject) {
    return (float) Math.toDegrees(Math.atan2(targetObject.getTransform().getPositionX() - rotatingVector.getX(),
            targetObject.getTransform().getPositionZ() - rotatingVector.getZ()));
}

From source file:MainActivity.java

private void calculateCompassDirection(SensorEvent event) {
    switch (event.sensor.getType()) {
    case Sensor.TYPE_ACCELEROMETER:
        mAccelerationValues = event.values.clone();
        break;//from ww  w. jav  a 2  s. c o m
    case Sensor.TYPE_MAGNETIC_FIELD:
        mGravityValues = event.values.clone();
        break;
    }
    boolean success = SensorManager.getRotationMatrix(mRotationMatrix, null, mAccelerationValues,
            mGravityValues);
    if (success) {
        float[] orientationValues = new float[3];
        SensorManager.getOrientation(mRotationMatrix, orientationValues);
        float azimuth = (float) Math.toDegrees(-orientationValues[0]);
        RotateAnimation rotateAnimation = new RotateAnimation(mLastDirectionInDegrees, azimuth,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        rotateAnimation.setDuration(50);
        rotateAnimation.setFillAfter(true);
        mImageViewCompass.startAnimation(rotateAnimation);
        mLastDirectionInDegrees = azimuth;
    }
}

From source file:org.apache.bigtop.bigpetstore.datagenerator.generators.locations.Location.java

public double distance(Pair<Double, Double> otherCoords) {
    double eps = 1e-3;
    if (Math.abs(coordinates.getLeft() - otherCoords.getLeft()) < eps
            && Math.abs(coordinates.getRight() - otherCoords.getRight()) < eps)
        return 0.0;

    double dist = Math.sin(Math.toRadians(coordinates.getLeft()))
            * Math.sin(Math.toRadians(otherCoords.getLeft()))
            + Math.cos(Math.toRadians(coordinates.getLeft())) * Math.cos(Math.toRadians(otherCoords.getLeft()))
                    * Math.cos(Math.toRadians(coordinates.getRight() - otherCoords.getRight()));
    dist = Math.toDegrees(Math.acos(dist)) * 69.09;

    return dist;/*from w w w.  java 2s.  c  o  m*/
}

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

/**
 *
 * @param direction/*www  . j  a  va  2s  .c o m*/
 *            +1 for out -1 for in
 * @param x0
 * @param y0
 * @param z0
 * @param thx
 * @param thy
 * @param p
 * @param charge
 */
public void SetSwimParameters(int direction, double x0, double y0, double z0, double thx, double thy, double p,
        int charge) {

    // x,y,z in m = swimmer units
    _x0 = x0 / 100;
    _y0 = y0 / 100;
    _z0 = z0 / 100;
    this.checkR(_x0, _y0, _z0);
    double pz = direction * 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 = direction * charge;
}

From source file:ceptraj.tool.Bearing.java

public static double bearing(Point p1, Point p2) {
    double bearing = 0;
    if (p1 != null && p2 != null) {

        switch (ConfigProvider.getSpaceType()) {
        case lat_lon:
            //In case of lat-lon space
            double p1LatRad = Math.toRadians(p1.getLat());
            double p2LatRad = Math.toRadians(p2.getLat());

            double p1LonRad = Math.toRadians(p1.getLon());
            double p2LonRad = Math.toRadians(p2.getLon());

            bearing = (Math
                    .toDegrees((Math.atan2(Math.sin(p2LonRad - p1LonRad) * Math.cos(p2LatRad),
                            Math.cos(p1LatRad) * Math.sin(p2LatRad)
                                    - Math.sin(p1LatRad) * Math.cos(p2LatRad) * Math.cos(p2LonRad - p1LonRad))))
                    + 360) % 360;/* w  w w  . j ava 2 s .  c  o m*/
            break;
        case cartesian:
            //In case of cartesian space
            double dy = p2.y - p1.y;
            double dx = p2.x - p1.x;
            bearing = 90 - (180 / Math.PI) * Math.atan2(dy, dx);
            if (bearing < 0) {
                bearing += 360;
            }
            break;
        }
    }

    return bearing;
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.entity.forward.MCEntityTransform.java

@Override
public void setRotation(Rotation rotation) {
    double[] euler = rotation.getAngles(RotationUtil.DEFAULT_ORDER);
    wrapper.rotationYaw = (float) Math.toDegrees(euler[0]);
    wrapper.rotationPitch = (float) Math.toDegrees(euler[1]);
}

From source file:org.gearvrf.keyboard.util.Util.java

public static float getZRotationAngle(GVRSceneObject rotatingObject, GVRSceneObject targetObject) {
    float angle = (float) Math.toDegrees(Math.atan2(
            targetObject.getTransform().getPositionY() - rotatingObject.getTransform().getPositionY(),
            targetObject.getTransform().getPositionX() - rotatingObject.getTransform().getPositionX()));

    return angle;
}

From source file:pt.lsts.neptus.plugins.urready4os.IverPlanExporter.java

private String iverWaypoint(int wptNum, double speedMps, /*double prevLength,*/ double yoyoAmplitude,
        double pitchDegs, ManeuverLocation prev, ManeuverLocation dst) {

    StringBuilder sb = new StringBuilder();
    sb.append(wptNum + "; ");
    dst.convertToAbsoluteLatLonDepth();//from   ww  w  . j a v  a 2  s. c o  m
    sb.append(String.format(Locale.US, "%.6f; ", dst.getLatitudeDegs()));
    sb.append(String.format(Locale.US, "%.6f; ", dst.getLongitudeDegs()));
    if (prev == null) {
        sb.append("0.0; ");
        sb.append("0.0; ");
    } else {
        sb.append(String.format(Locale.US, "%.3f; ", /*prevLength +*/ prev.getDistanceInMeters(dst)));
        sb.append(String.format(Locale.US, "%.2f; ", Math.toDegrees(prev.getXYAngle(dst))));
    }

    if (yoyoAmplitude == 0) {

        switch (dst.getZUnits()) {
        case DEPTH:
            sb.append(String.format(Locale.US, "D%.1f ", metersToFeet(dst.getZ())));
            break;
        case ALTITUDE:
            sb.append(String.format(Locale.US, "H%.1f ", metersToFeet(dst.getZ())));
            break;
        default:
            sb.append("D0.00 ");
            break;
        }
    } else {
        sb.append(String.format(Locale.US, "U%.1f,%.1f,%.1f ", metersToFeet((dst.getZ() - yoyoAmplitude)),
                metersToFeet((dst.getZ() + yoyoAmplitude)), pitchDegs));
    }

    sb.append(
            String.format(Locale.US, "P0 VC1,0,0,1000,0,VC2,0,0,1000,0 S%.1f; 0;-1\r\n", mpsToKnots(speedMps)));

    return sb.toString();
}