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:ai.grakn.graql.internal.shell.animalia.chordata.mammalia.artiodactyla.hippopotamidae.HippopotamusFactory.java

/**
 * Raise population of hippopotamus amphibius within console.
 * @param console/*from w  w w.jav a  2  s  . c om*/
 */
public static void increasePop(ConsoleReader console) {
    HippopotamusFactory builder = HippopotamusFactory.builder();

    if (System.getenv("HIPPO_SIZE") != null) {
        int hippoSize = Integer.parseInt(System.getenv("HIPPO_SIZE"));
        builder.size(hippoSize);
    }

    Hippopotamus hippo = builder.build();

    try {
        for (double i = 0; i < Math.PI; i += 0.1) {
            console.println(hippo.toString().replaceAll("^|\n",
                    "\n" + StringUtils.repeat(" ", (int) (Math.sin(i) * 100))));
            console.flush();
            Thread.sleep(100);
        }
    } catch (IOException | InterruptedException e) {
        System.err.println("Supercalafrajilistichippopotamusexception");
    }

    hippo.submerge();

    console.setPrompt(hippo.toString());
}

From source file:de.termininistic.serein.examples.benchmarks.functions.multimodal.AckleyFunction.java

@Override
public double map(RealVector v) {
    double[] x = v.toArray();
    int n = x.length;
    double sum1 = 0.0, sum2 = 0.0;

    for (int i = 0; i < n; i++) {
        sum1 += x[i] * x[i];/*from   www  .  j a v a  2  s  .com*/
        sum2 += Math.cos(2 * Math.PI * x[i]);
    }
    double fx = -20 * Math.exp(-0.2 * Math.sqrt(sum1 / n)) - Math.exp(sum2 / n) + 20 + Math.E;
    return fx;
}

From source file:Float11.java

static public double acos(double x) {
    double f = asin(x);
    if (f == Double.NaN)
        return f;
    return Math.PI / 2 - f;
}

From source file:MathUtil.java

/** Arcus cos */
static public double acos(double x) {
    double f = asin(x);
    if (f == Double.NaN) {
        return f;
    }/*from w  w  w  .  j  a  v a  2  s . co m*/
    return Math.PI / 2 - f;
}

From source file:edu.esprit.pi.workshop.statistiques.BarChart.java

@Override
public JFreeChart construireChart2D() {
    graphe = ChartFactory.createBarChart("Pourcentage revenue par Dpartement", "Departement",
            "Pourcentage du revenu", createDataset(), PlotOrientation.VERTICAL, true, true, true);
    final CategoryPlot plot = graphe.getCategoryPlot();
    final CategoryAxis axis = plot.getDomainAxis();
    axis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0));
    final CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setItemLabelsVisible(true);
    return graphe;
}

From source file:com.hurence.tmp.FFT.java

public static Complex[] fft(Complex[] x) {
    int N = x.length;

    // base case//  w  w w  .j  a  v  a 2s  . c  o m
    if (N == 1) {
        return new Complex[] { x[0] };
    }

    // radix 2 Cooley-Tukey FFT
    if (N % 2 != 0) {
        throw new RuntimeException("N is not a power of 2");
    }

    // fft of even terms
    Complex[] even = new Complex[N / 2];
    for (int k = 0; k < N / 2; k++) {
        even[k] = x[2 * k];
    }
    Complex[] q = fft(even);

    // fft of odd terms
    Complex[] odd = even; // reuse the array
    for (int k = 0; k < N / 2; k++) {
        odd[k] = x[2 * k + 1];
    }
    Complex[] r = fft(odd);

    // combine
    Complex[] y = new Complex[N];
    for (int k = 0; k < N / 2; k++) {
        double kth = -2 * k * Math.PI / N;
        Complex wk = new Complex(Math.cos(kth), Math.sin(kth));
        y[k] = q[k].add(wk.multiply(r[k]));
        y[k + N / 2] = q[k].subtract(wk.multiply(r[k]));
    }
    return y;
}

From source file:com.mapr.synth.drive.DriveTest.java

@Test
public void testPlanning() throws FileNotFoundException {
    Random rand = new Random(3);
    GeoPoint start = new GeoPoint((rand.nextDouble() - 0.5) * Math.PI / 2, rand.nextDouble() * Math.PI * 2);
    GeoPoint end = start.nearby(10, rand);

    Vector3D east = start.east();
    Vector3D north = start.north(east);
    try (PrintWriter out = new PrintWriter(new File("short-drive.csv"))) {
        out.printf("i, highway, x0, y0, x1, y1");
        double highway = 0;
        int n = 0;
        for (int i = 0; i < 50; i++) {
            List<Car.Segment> plan = Car.plan(start, end, rand);
            assertTrue(plan.size() < 20);
            Vector3D here = project(east, north, start.as3D());
            for (Car.Segment segment : plan) {
                Vector3D step = project(east, north, segment.getEnd().as3D());
                n++;//w  w  w  .ja v  a2  s  .  c  o  m
                if (segment instanceof Car.Highway) {
                    highway++;
                }
                out.printf("%d, %d, %.4f, %.4f, %.4f, %.4f\n", i, (segment instanceof Car.Local) ? 1 : 0,
                        here.getX(), here.getY(), step.getX(), step.getY());
                here = step;
            }

            // should arrive at our destination!
            assertEquals(0.0, here.subtract(project(east, north, end.as3D())).getNorm(), 0.01);
        }
        // most steps should be local, not highway
        assertEquals(0.0, highway / n, 0.1);
    }
}

From source file:fsm.series.Series_SS.java

@Override
public double getFirstDerivativeValue(double y, int m) {
    return Math.cos(m * Math.PI * y / a) * m * Math.PI / a;
}

From source file:FarbWurfelAsQuads.java

/**
 * Erstellt den Szenegraphen//from   w w  w.  j  a  va2 s .  c om
 * 
 * @return BranchGroup
 */
public BranchGroup macheSzene() {
    BranchGroup objWurzel = new BranchGroup();
    // Transformation, 2 Rotationen:
    Transform3D drehung = new Transform3D();
    Transform3D drehung2 = new Transform3D();
    drehung.rotX(Math.PI / 4.0d);
    drehung2.rotY(Math.PI / 5.0d);
    drehung.mul(drehung2);
    drehung.setScale(0.5d);
    TransformGroup objDreh = new TransformGroup(drehung);
    Shape3D shape = new Shape3D(makeCube(), makeAppearance());
    objDreh.addChild(shape);

    objWurzel.addChild(objDreh);
    return objWurzel;
}

From source file:de.termininistic.serein.examples.benchmarks.functions.multimodal.MichalewiczFunction.java

@Override
public double map(RealVector v) {
    double[] x = v.toArray();
    double sum = 0.0;
    for (int i = 0; i < x.length; i++) {
        sum += Math.sin(x[i]) * Math.pow(Math.sin((i + 1) * x[i] * x[i] / Math.PI), 2 * m);
    }//  www .  ja v a  2s.c  o m
    return -sum;
}