Example usage for java.lang Math sin

List of usage examples for java.lang Math sin

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static double sin(double a) 

Source Link

Document

Returns the trigonometric sine of an angle.

Usage

From source file:de.thkwalter.et.pulsmuster.Differenzsignal.java

/**
 * Diese Methode gibt den Funktionswert zurck.
 * /*ww  w . j a  v  a 2s.com*/
 * @param x Die unabhngige Variable
 * 
 * @return Der Funktionswert
 * 
 * @see UnivariateFunction#value(double)
 */
@Override
public double value(double x) {
    // Der Funktionswert wird zurckgegeben.
    return this.m * x + this.t - Math.sin(x);
}

From source file:fsm.series.Series_SS.java

@Override
public double getFirstDerivativeIntegral(int m) {
    return Math.sin(Math.PI * m);
}

From source file:frk.gpssimulator.support.NavUtils.java

/**
 * Returns coordinates of position which is given distance and bearing from given point.
 * @param pt1/*from  ww w  .  j ava2  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), null);

}

From source file:com.wheelermarine.publicAccessSites.Updater.java

/**
 * Convert a UTM location to a latitude and longitude location.
 *
 * @param north the northing value.//  w  w  w. ja va  2s  .  co m
 * @param east  the easting value.
 * @param zone  the UTM zone.
 * @return a Location containing the latitude and longitude.
 */
public static Location fromUTM(double north, double east, double zone) {

    double d = 0.99960000000000004;
    double d1 = 6378137;
    double d2 = 0.0066943799999999998;
    double d4 = (1 - Math.sqrt(1 - d2)) / (1 + Math.sqrt(1 - d2));
    double d3 = d2 / (1 - d2);
    double d12 = (north / d) / (d1 * (1 - d2 / 4 - (3 * d2 * d2) / 64 - (5 * Math.pow(d2, 3)) / 256));
    double d14 = d12 + ((3 * d4) / 2 - (27 * Math.pow(d4, 3)) / 32) * Math.sin(2 * d12)
            + ((21 * d4 * d4) / 16 - (55 * Math.pow(d4, 4)) / 32) * Math.sin(4 * d12)
            + ((151 * Math.pow(d4, 3)) / 96) * Math.sin(6 * d12);
    double d5 = d1 / Math.sqrt(1 - d2 * Math.sin(d14) * Math.sin(d14));
    double d6 = Math.tan(d14) * Math.tan(d14);
    double d7 = d3 * Math.cos(d14) * Math.cos(d14);
    double d8 = (d1 * (1 - d2)) / Math.pow(1 - d2 * Math.sin(d14) * Math.sin(d14), 1.5);
    double d9 = (east - 500000) / (d5 * d);
    double lat = (d14 - ((d5 * Math.tan(d14)) / d8)
            * (((d9 * d9) / 2 - (((5 + 3 * d6 + 10 * d7) - 4 * d7 * d7 - 9 * d3) * Math.pow(d9, 4)) / 24)
                    + (((61 + 90 * d6 + 298 * d7 + 45 * d6 * d6) - 252 * d3 - 3 * d7 * d7) * Math.pow(d9, 6))
                            / 720))
            * 180 / Math.PI;
    double lon = (((zone - 1) * 6 - 180) + 3) + (((d9 - ((1 + 2 * d6 + d7) * Math.pow(d9, 3)) / 6)
            + (((((5 - 2 * d7) + 28 * d6) - 3 * d7 * d7) + 8 * d3 + 24 * d6 * d6) * Math.pow(d9, 5)) / 120)
            / Math.cos(d14)) * 180 / Math.PI;
    Location loc = new Location("MNDNR");
    loc.setLatitude(lat);
    loc.setLongitude(lon);
    return loc;
}

From source file:gdsc.smlm.function.gaussian.SingleFreeCircularGaussian2DFunction.java

public void initialise(double[] a) {
    background = a[BACKGROUND];/* www  .  java2s  .  co m*/
    x0pos = a[X_POSITION];
    x1pos = a[Y_POSITION];

    // Precalculate multiplication factors
    final double theta = a[ANGLE];
    final double sx = a[X_SD];
    final double sy = a[Y_SD];
    final double sx2 = sx * sx;
    final double sy2 = sy * sy;
    final double sx3 = sx2 * sx;
    final double sy3 = sy2 * sy;
    final double cosSqt = Math.cos(theta) * Math.cos(theta);
    final double sinSqt = Math.sin(theta) * Math.sin(theta);
    final double sin2t = Math.sin(2 * theta);

    n = ONE_OVER_TWO_PI / (sx * sy);
    height = a[SIGNAL] * n;

    // All prefactors are negated since the Gaussian uses the exponential to the negative:
    // (A/2*pi*sx*sy) * exp( -( a(x-x0)^2 + 2b(x-x0)(y-y0) + c(y-y0)^2 ) )

    aa = -0.5 * (cosSqt / sx2 + sinSqt / sy2);
    bb = -0.25 * (-sin2t / sx2 + sin2t / sy2);
    cc = -0.5 * (sinSqt / sx2 + cosSqt / sy2);

    // For the x-width gradient
    nx = -1 / sx;
    ax = cosSqt / sx3;
    bx = -0.5 * sin2t / sx3;
    cx = sinSqt / sx3;

    // For the y-width gradient
    ny = -1 / sy;
    ay = sinSqt / sy3;
    by = 0.5 * sin2t / sy3;
    cy = cosSqt / sy3;
}

From source file:at.uni_salzburg.cs.ros.artificer.LocationData.java

/**
 * @param configuration configuration/*from  ww w . j a va  2  s.c om*/
 * @param location location
 */
public LocationData(Configuration configuration, Location location) {
    clock = configuration.getClock();
    this.location = location;
    simDetails = configuration.getLocationSimulationDetails();
    velocity = simDetails.get(location.getLocationId()).getAverageSpeed();
    mutation = simDetails.get(location.getLocationId()).getMutationSpeed();

    minLatitude = simDetails.get(location.getLocationId()).getMinLatitude();
    maxLatitude = simDetails.get(location.getLocationId()).getMaxLatitude();
    minLongitude = simDetails.get(location.getLocationId()).getMinLongitude();
    maxLongitude = simDetails.get(location.getLocationId()).getMaxLongitude();

    moving = Math.abs(velocity) > 1E-6 || Math.abs(mutation) > 1E-4;
    heading = RandomUtils.nextDouble() * 2.0 * Math.PI;
    headingSouth = Math.sin(heading) * velocity;
    headingEast = Math.cos(heading) * velocity;
}

From source file:com.griddynamics.jagger.reporting.LatencyPlotReportProvider.java

private JFreeChart createChart(String title) {

    if (false) {/*from w  ww .ja  v a 2  s.c om*/
        Map<Date, Double> s1 = new HashMap<Date, Double>();
        Map<Date, Double> s2 = new HashMap<Date, Double>();
        long time = System.currentTimeMillis();
        for (int i = 0; i < 100; i++) {
            s1.put(new Date(time + i * 1000), Math.sin(i / 10.0));
            s2.put(new Date(time + i * 1000), Math.cos(i / 5.0));
        }
        ChartHelper.TimeSeriesChartSpecification spec1 = new ChartHelper.TimeSeriesChartSpecification();
        spec1.setData(s1);
        spec1.setLabel("Latency 1");
        ChartHelper.TimeSeriesChartSpecification spec2 = new ChartHelper.TimeSeriesChartSpecification();
        spec2.setData(s2);
        spec2.setLabel("Latency 2");

        return ChartHelper.createTimeSeriesChart(title, Arrays.asList(spec1, spec2), "Time", "Latency",
                ChartHelper.ColorTheme.LIGHT);
    }

    if (false) {

        List<List<Double>> data = getBarData();
        List<String> zoneLabels = new ArrayList<String>();
        for (int i = 0; i < 16; i++) {
            zoneLabels.add(i + "%");
        }
        JFreeChart chart = ChartHelper.createStackedBarChart(title, data, zoneLabels, "Time", "Latency",
                ChartHelper.ColorTheme.DARK);

        return chart;
    }

    if (true) {
        XYSeriesCollection areas = getSeriesCollection(16);
        XYSeriesCollection lines = getSeriesCollection(2);
        JFreeChart chart = ChartHelper.createStackedAreaChart(title, areas, lines, "Time", "Latency",
                ChartHelper.ColorTheme.LIGHT);

        return chart;
    }

    return null;
}

From source file:etomica.math.SpecialFunctions.java

public static double gamma(double x) {
    if (x == 0) {
        return 1;
    }//from  w  ww .ja  v  a2 s .c o  m
    if (x < 0.5) {
        return Math.PI / (Math.sin(Math.PI * x) * gamma(1 - x));
    }
    double y = Math.exp(lnGamma(x));
    return y;
}

From source file:gdsc.smlm.function.gaussian.SingleEllipticalGaussian2DFunction.java

public void initialise(double[] a) {
    background = a[BACKGROUND];/*from w  w w  .  jav  a  2s .c  o m*/
    x0pos = a[X_POSITION];
    x1pos = a[Y_POSITION];

    // Precalculate multiplication factors
    final double theta = a[ANGLE];
    final double sx = a[X_SD];
    final double sy = a[Y_SD];
    final double sx2 = sx * sx;
    final double sy2 = sy * sy;
    final double sx3 = sx2 * sx;
    final double sy3 = sy2 * sy;
    final double cosSqt = Math.cos(theta) * Math.cos(theta);
    final double sinSqt = Math.sin(theta) * Math.sin(theta);
    final double sincost = Math.sin(theta) * Math.cos(theta);
    final double sin2t = Math.sin(2 * theta);
    final double cos2t = Math.cos(2 * theta);

    n = ONE_OVER_TWO_PI / (sx * sy);
    height = a[SIGNAL] * n;

    // All prefactors are negated since the Gaussian uses the exponential to the negative:
    // (A/2*pi*sx*sy) * exp( -( a(x-x0)^2 + 2b(x-x0)(y-y0) + c(y-y0)^2 ) )

    aa = -0.5 * (cosSqt / sx2 + sinSqt / sy2);
    bb = -0.25 * (-sin2t / sx2 + sin2t / sy2);
    cc = -0.5 * (sinSqt / sx2 + cosSqt / sy2);

    // For the angle gradient
    aa2 = -(-sincost / sx2 + sincost / sy2);
    bb2 = -0.5 * (-cos2t / sx2 + cos2t / sy2);
    cc2 = -(sincost / sx2 - sincost / sy2);

    // For the x-width gradient
    nx = -1 / sx;
    ax = cosSqt / sx3;
    bx = -0.5 * sin2t / sx3;
    cx = sinSqt / sx3;

    // For the y-width gradient
    ny = -1 / sy;
    ay = sinSqt / sy3;
    by = 0.5 * sin2t / sy3;
    cy = cosSqt / sy3;
}

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