Example usage for java.lang Math PI

List of usage examples for java.lang Math PI

Introduction

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

Prototype

double PI

To view the source code for java.lang Math PI.

Click Source Link

Document

The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.

Usage

From source file:fsm.series.Series_SS.java

@Override
public double getYmIntegral(int m) {

    double pi = Math.PI;
    return a / (pi * m) - (a * cos(pi * m)) / (pi * m);

}

From source file:com.jennifer.ui.chart.grid.RadarGrid.java

@Override
public void drawBefore() {
    initDomain();/*from ww  w.ja v a 2s  .  c  o m*/

    int width = chart.area("width"), height = chart.area("height");
    int min = width;

    if (height < min) {
        min = height;
    }

    // default value ;
    domain = options.getJSONArray("domain");
    step = options.optInt("step", 10);

    // center
    w = min / 2.0;
    centerX = chart.area("x") + width / 2.0;
    centerY = chart.area("y") + height / 2.0;
    count = domain.length();
    unit = 2 * Math.PI / count;
    h = Math.abs(w) / step;
    hideText = options.optBoolean("hideText", false);
    line = options.optBoolean("line", true);
    extra = options.optBoolean("extra", false);
    shape = options.optString("shape", "radial");
    max = options.optDouble("max", 100);
    stepValue = max / step;

}

From source file:es.udc.gii.common.eaf.benchmark.multiobjective.dtlz2.R_Dtlz2_Objective.java

@Override
public double evaluate(double[] x) {

    int nx = x.length;

    int i = 0, j = 0;
    int k = nx - numberOfObjectives + 1;
    double g = 0;

    double[] z = new double[nx];
    double[] zz = new double[nx];
    double[] p = new double[nx];
    double[] psum = new double[numberOfObjectives];

    // denormalize vector:
    for (i = 0; i < nx; i++) {
        x[i] = (bounds[1][i] - bounds[0][i]) / 2 * x[i] + (bounds[1][i] + bounds[0][i]) / 2;
    }//from  w ww  .  j  a  v a  2 s .  com

    for (i = 0; i < nx; i++) {
        z[i] = 0;
        for (j = 0; j < nx; j++) {
            z[i] += M[i][j] * x[j];
        }
        if (z[i] >= 0 && z[i] <= 1) {
            zz[i] = z[i];
            p[i] = 0;
        } else if (z[i] < 0) {
            zz[i] = -lambda[i] * z[i];
            p[i] = -z[i];
        } else {
            zz[i] = 1 - lambda[i] * (z[i] - 1);
            p[i] = z[i] - 1;
        }
    }

    for (j = 0; j < numberOfObjectives; j++) {
        psum[j] = 0;
    }

    for (i = nx - k + 1; i <= nx; i++) {
        g += Math.pow(zz[i - 1] - 0.5, 2) - Math.cos(20 * Math.PI * (zz[i - 1] - 0.5));
        for (j = 0; j < numberOfObjectives; j++) {
            psum[j] = Math.sqrt(Math.pow(psum[j], 2) + Math.pow(p[i - 1], 2));
        }
    }

    g = 100 * (k + g);

    double ff = (1 + g);

    for (j = numberOfObjectives - objNumber; j >= 1; j--) {
        ff *= Math.cos(zz[j - 1] * Math.PI / 2.0);
        psum[objNumber - 1] = Math.sqrt(Math.pow(psum[objNumber - 1], 2) + Math.pow(p[j - 1], 2));
    }

    if (objNumber > 1) {
        ff *= Math.sin(zz[(numberOfObjectives - objNumber + 1) - 1] * Math.PI / 2.0);
        psum[objNumber - 1] = Math.sqrt(
                Math.pow(psum[objNumber - 1], 2) + Math.pow(p[(numberOfObjectives - objNumber + 1) - 1], 2));
    }

    return 2.0 / (1 + Math.exp(-psum[objNumber - 1])) * (ff + 1);
}

From source file:es.udc.gii.common.eaf.benchmark.multiobjective.dtlz2.S_Dtlz2_Objective.java

@Override
public double evaluate(double[] x) {
    int nx = x.length;

    int i = 0;/*  www  .  ja v a 2s .  c o m*/
    int j = 0;
    int k = nx - numberOfObjectives + 1;
    double g = 0;
    double[] z = new double[nx];
    double[] zz = new double[nx];
    double[] p = new double[nx];
    double[] psum = new double[numberOfObjectives];

    // denormalize vector:
    for (i = 0; i < nx; i++) {
        x[i] = (bounds[1][i] - bounds[0][i]) / 2 * x[i] + (bounds[1][i] + bounds[0][i]) / 2;
    }

    for (i = 0; i < nx; i++) {
        z[i] = x[i] - o[i];

        if (z[i] < 0) {
            zz[i] = -lambda[i] * z[i];
            p[i] = -z[i] / d[i];
        } else {
            zz[i] = z[i];
            p[i] = 0;
        }
    }

    for (j = 0; j < numberOfObjectives; j++) {
        psum[j] = 0;
    }

    for (i = nx - k + 1; i <= nx; i++) {
        g += Math.pow(zz[i - 1] - 0.5, 2);
        for (j = 0; j < numberOfObjectives; j++) {
            psum[j] = Math.sqrt(Math.pow(psum[j], 2) + Math.pow(p[i - 1], 2));
        }
    }

    double ff = (1 + g);

    for (j = numberOfObjectives - objNumber; j >= 1; j--) {
        ff *= Math.cos(zz[j - 1] * Math.PI / 2.0);
        psum[objNumber - 1] = Math.sqrt(Math.pow(psum[objNumber - 1], 2) + Math.pow(p[j - 1], 2));
    }

    if (objNumber > 1) {
        ff *= Math.sin(zz[(numberOfObjectives - objNumber + 1) - 1] * Math.PI / 2.0);
        psum[objNumber - 1] = Math.sqrt(
                Math.pow(psum[objNumber - 1], 2) + Math.pow(p[(numberOfObjectives - objNumber + 1) - 1], 2));
    }

    return 2.0 / (1 + Math.exp(-psum[objNumber - 1])) * (ff + 1);
}

From source file:uk.org.funcube.fcdw.service.PredictorService.java

public SatellitePosition get(Long catnum, Date instant, GroundStationPosition groundStationPosition) {

    SatellitePosition position = null;/*from w  w w.ja va 2  s . c  o  m*/

    List<TleEntity> tleEntities = tleDao.findByCatnum(catnum);

    if (!tleEntities.isEmpty()) {
        final TleEntity tleEntity = tleEntities.get(0);
        final TLE tle = new TLE(tleEntity.getCatnum(), tleEntity.getName(), tleEntity.getSetnum(),
                tleEntity.getYear(), tleEntity.getRefepoch(), tleEntity.getIncl(), tleEntity.getRaan(),
                tleEntity.getEccn(), tleEntity.getArgper(), tleEntity.getMeanan(), tleEntity.getMeanmo(),
                tleEntity.getDrag(), tleEntity.getNddot6(), tleEntity.getBstar(), tleEntity.getOrbitnum(),
                tleEntity.getEpoch(), tleEntity.getXndt2o(), tleEntity.getXincl(), tleEntity.getXnodeo(),
                tleEntity.getEo(), tleEntity.getOmega(), tleEntity.getMo(), tleEntity.getXno(),
                tleEntity.isDeepspace(), tleEntity.getCreateddate());

        Satellite satellite = SatelliteFactory.createSatellite(tle);

        satellite.calculateSatelliteVectors(instant);
        satellite.calculateSatelliteGroundTrack();

        SatPos satPos = satellite.calculateSatPosForGroundStation(groundStationPosition);

        final NumberFormat numberFormat = NumberFormat.getNumberInstance();
        numberFormat.setMaximumFractionDigits(2);

        position = new SatellitePosition(numberFormat.format(satPos.getLatitude() / (Math.PI * 2.0) * 360),
                numberFormat.format(satPos.getLongitude() / (Math.PI * 2.0) * 360),
                satPos.isEclipsed() ? "yes" : "no", numberFormat.format(satPos.getEclipseDepth()),
                satPos.isAboveHorizon());
    }

    return position;
}

From source file:TransformersRotation.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    // Use antialiasing.
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // Move the origin to 75, 75.
    AffineTransform at = AffineTransform.getTranslateInstance(75, 75);
    g2.transform(at);//from  w w  w . jav  a 2s. c  om

    // Draw the shapes in their original locations.
    g2.setPaint(Color.black);
    g2.draw(axes);
    g2.draw(shape);

    // Transform the Graphics2D.
    g2.transform(AffineTransform.getRotateInstance(-Math.PI / 6));

    // Draw the "new" shapes in dashed.
    Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 },
            0);
    g2.setStroke(stroke);
    g2.draw(axes);
    g2.draw(shape);
}

From source file:org.jfree.data.function.NormalDistributionFunction2D.java

/**
 * Constructs a new normal distribution function.
 *
 * @param mean  the mean./*from  w  ww .j  a v a 2  s.  co m*/
 * @param std  the standard deviation (&gt; 0).
 */
public NormalDistributionFunction2D(double mean, double std) {
    if (std <= 0) {
        throw new IllegalArgumentException("Requires 'std' > 0.");
    }
    this.mean = mean;
    this.std = std;
    // calculate constant values
    this.factor = 1 / (std * Math.sqrt(2.0 * Math.PI));
    this.denominator = 2 * std * std;
}

From source file:utils.RandomVariable.java

/**
 * Generate a random number from a Gaussian (Normal) random variable.
 *
 * @param mu mean of the random variable.
 * @param sigma standard deviation of the random variable.
 * @return a double.//from  www .  ja  va 2  s .com
 */
public static double normal(double mu, double sigma) {
    double x = mu + sigma * Math.cos(2 * Math.PI * rand()) * Math.sqrt(-2 * Math.log(rand()));
    return x;
}

From source file:TransformTranslatedRotation.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    // Use antialiasing.
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // Move the origin to 75, 75.
    AffineTransform at = AffineTransform.getTranslateInstance(75, 75);
    g2.transform(at);//from  w ww. j  a v a2 s  .c  o m

    // Draw the shapes in their original locations.
    g2.setPaint(Color.black);
    g2.draw(axes);
    g2.draw(shape);

    // Transform the Graphics2D.
    float cm = 72 / 2.54f;
    g2.transform(AffineTransform.getRotateInstance(-Math.PI / 6, 3 * cm, 2 * cm));

    // Draw the "new" shapes in dashed.
    Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 },
            0);
    g2.setStroke(stroke);
    g2.draw(axes);
    g2.draw(shape);
}

From source file:TransformersRotationTranslation.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    // Use antialiasing.
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // Move the origin to 75, 75.
    AffineTransform at = AffineTransform.getTranslateInstance(75, 75);
    g2.transform(at);//  ww w  . j av  a  2s.  c o  m

    // Draw the shapes in their original locations.
    g2.setPaint(Color.black);
    g2.draw(axes);
    g2.draw(shape);

    // Transform the Graphics2D.
    AffineTransform rat = new AffineTransform();
    rat.setToRotation(Math.PI / 6);
    rat.translate(100, 100);

    g2.transform(rat);

    // Draw the "new" shapes in dashed.
    Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 },
            0);
    g2.setStroke(stroke);
    g2.draw(axes);
    g2.draw(shape);
}