Example usage for java.lang Math toRadians

List of usage examples for java.lang Math toRadians

Introduction

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

Prototype

public static double toRadians(double angdeg) 

Source Link

Document

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

Usage

From source file:com.rks.musicx.misc.widgets.DiagonalLayout.java

private void calculateLayout() {
    if (settings == null) {
        return;/*ww w  .  ja  va2  s . c o  m*/
    }
    height = getMeasuredHeight();
    width = getMeasuredWidth();
    if (width > 0 && height > 0) {

        final float perpendicularHeight = (float) (width * Math.tan(Math.toRadians(settings.getAngle())));

        clipPath = createClipPath(perpendicularHeight);
        outlinePath = createOutlinePath(perpendicularHeight);

        handleMargins(perpendicularHeight);

        ViewCompat.setElevation(this, settings.getElevation());

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            setOutlineProvider(getOutlineProvider());
        }
    }
}

From source file:de.codesourcery.geoip.Coordinate.java

public double longitudeInRad() {
    return Math.toRadians(longitudeInDeg);
}

From source file:de.codesourcery.geoip.Coordinate.java

public double latitudeInRad() {
    return Math.toRadians(latitudeInDeg);
}

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/*  w w w.  j av  a2  s.c om*/
                    .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;
            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:demo.support.NavUtils.java

/**
 * Returns coordinates of position which is given distance and bearing from given point.
 * @param pt1//from   w ww.  j  av  a 2 s .c o m
 * @param dist
 * @param brg
 * @return
 */
public static Point getPosition(Point pt1, double d, double brg) {
    if (Double.doubleToRawLongBits(d) == 0) {
        return pt1;
    }

    double lat1 = Math.toRadians(pt1.getLatitude());
    double lon1 = Math.toRadians(pt1.getLongitude());
    double brgAsRadians = Math.toRadians(brg);

    double lat2 = Math.asin(Math.sin(lat1) * Math.cos(d / EARTH_RADIUS_IN_METERS)
            + Math.cos(lat1) * Math.sin(d / EARTH_RADIUS_IN_METERS) * Math.cos(brgAsRadians));
    double x = Math.sin(brgAsRadians) * Math.sin(d / EARTH_RADIUS_IN_METERS) * Math.cos(lat1);
    double y = Math.cos(d / EARTH_RADIUS_IN_METERS) - Math.sin(lat1) * Math.sin(lat2);
    double lon2 = lon1 + Math.atan2(x, y);

    return new Point(Math.toDegrees(lat2), Math.toDegrees(lon2));

}

From source file:uk.org.todome.Util.java

public static double getDistanceBetween(GeoPoint point1, GeoPoint point2) {
    // Implemented from code at
    // http://www.movable-type.co.uk/scripts/latlong.html
    int R = 6371; // radius of Earth in km

    double lat2 = Math.toRadians(point2.getLatitudeE6() * 1e-6);
    double lat1 = Math.toRadians(point1.getLatitudeE6() * 1e-6);

    double dLat = lat2 - lat1;
    double dLon = Math.toRadians((point2.getLongitudeE6() - point1.getLongitudeE6()) * 1e-6);

    double a = Math.sin(dLat / 2) * Math.sin(dLat / 2)
            + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(lat1) * Math.cos(lat2);
    double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
    double d = R * c;

    return d;// w ww . ja  va  2 s  . com
}

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

@Override
public Rotation rotation() {
    return new Rotation(RotationUtil.DEFAULT_ORDER, -Math.toRadians(wrapper.rotationYaw) - Math.PI,
            -Math.toRadians(wrapper.rotationPitch), 0);
}

From source file:com.crossover.trial.weather.domain.Airport.java

public double calculateDistance(Airport toAirport) {
    Assert.isTrue(toAirport != null, "airport is required");
    double deltaLat = Math.toRadians(toAirport.latitude - latitude);
    double deltaLon = Math.toRadians(toAirport.longitude - longitude);
    double a = Math.pow(Math.sin(deltaLat / 2), 2)
            + Math.pow(Math.sin(deltaLon / 2), 2) * Math.cos(latitude) * Math.cos(toAirport.latitude);
    double c = 2 * Math.asin(Math.sqrt(a));
    return EARTH_RADIUS * c;
}

From source file:org.n52.oss.IT.OpenSearchSpatialExtensionIT.java

public static double haversine(double lat1, double lon1, double lat2, double lon2) {
    double dLat = Math.toRadians(lat2 - lat1);
    double dLon = Math.toRadians(lon2 - lon1);
    lat1 = Math.toRadians(lat1);/*from   ww  w  . j  av a  2  s  . c o m*/
    lat2 = Math.toRadians(lat2);

    double a = Math.sin(dLat / 2) * Math.sin(dLat / 2)
            + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(lat1) * Math.cos(lat2);
    double c = 2 * Math.asin(Math.sqrt(a));
    return R * c;
}

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()));
}