List of usage examples for java.lang Math PI
double PI
To view the source code for java.lang Math PI.
Click Source Link
From source file:io.yields.math.concepts.operator.CurveLengthTest.java
@Test public void testFailoverCalculation() { Function<Double, Double> curve = x -> Math.sin(x); Assertions.assertThat(length().between(0, 2 * Math.PI).apply(curve)) .isEqualTo(length().between(0, 2 * Math.PI).simpsonIntegration(curve), Delta.delta(1.e-8)); }
From source file:HelloJava3Dbalt.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // rotate object has composited transformation matrix Transform3D rotate = new Transform3D(); Transform3D tempRotate = new Transform3D(); rotate.rotX(Math.PI / 4.0d); tempRotate.rotY(Math.PI / 5.0d); tempRotate.mul(rotate);/*from w ww . j a v a2 s . co m*/ TransformGroup objRotate = new TransformGroup(tempRotate); objRoot.addChild(objRotate); objRotate.addChild(new ColorCube(0.4)); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:app.view.panel.PanelHistogramme.java
/** * Cre le graphique/*from w ww . java 2 s . co m*/ * * @param dataset Echantillon de donnes * @return Graphique */ private JFreeChart createChart(CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart3D("Sries de bac", // chart title "Bacs", // domain axis label "Nombre", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); final CategoryPlot plot = chart.getCategoryPlot(); final CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 8.0)); final BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer(); renderer.setDrawBarOutline(false); return chart; }
From source file:HelloJava3Db.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // rotate object has composited transformation matrix Transform3D rotate = new Transform3D(); Transform3D tempRotate = new Transform3D(); rotate.rotX(Math.PI / 4.0d); tempRotate.rotY(Math.PI / 5.0d); rotate.mul(tempRotate);/*from w w w .ja v a2 s .c o m*/ TransformGroup objRotate = new TransformGroup(rotate); objRoot.addChild(objRotate); objRotate.addChild(new ColorCube(0.4)); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:es.udc.gii.common.eaf.benchmark.multiobjective.sym_part.Sym_Part_Objective.java
protected int findTileSYMPART(double x1, double x2) { int i, j, dim; double[] x = new double[2]; double h1;//w w w .j ava2s . c o m double omega = Math.PI / 4.0; double si = Math.sin(omega), co = Math.cos(omega); x[0] = x1; x[1] = x2; //rotate( 2, x ); for (dim = 0; dim + 1 < 2; dim += 2) { h1 = x[dim]; x[dim] = co * h1 - si * x[dim + 1]; x[dim + 1] = si * h1 + co * x[dim + 1]; } int[] ij = findTile(x[0], x[1]); i = ij[0]; j = ij[1]; // restrict to 9 tiles if (Math.abs(i) > 1 || Math.abs(j) > 1) { return -1; } return (i + 1) * 3 + (j + 1); }
From source file:MathUtil.java
/** Arcus tan */ static public double atan(double x) { boolean signChange = false; boolean Invert = false; int sp = 0;//from ww w . j a va 2 s . c o m double x2, a; // check up the sign change if (x < 0.) { x = -x; signChange = true; } // check up the invertation if (x > 1.) { x = 1 / x; Invert = true; } // process shrinking the domain until x<PI/12 while (x > Math.PI / 12) { sp++; a = x + SQRT3; a = 1 / a; x = x * SQRT3; x = x - 1; x = x * a; } // calculation core x2 = x * x; a = x2 + 1.4087812; a = 0.55913709 / a; a = a + 0.60310579; a = a - (x2 * 0.05160454); a = a * x; // process until sp=0 while (sp > 0) { a = a + Math.PI / 6; sp--; } // invertation took place if (Invert) { a = Math.PI / 2 - a; } // sign change took place if (signChange) { a = -a; } // return a; }
From source file:controle.JfreeChartController.java
private DefaultCategoryDataset createDataset() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (double i = 0; i <= 10; i += 0.1) { dataset.addValue(Math.cos(Math.PI * i), "cosseno", Double.valueOf(i)); }/*from w ww . ja v a2s. c om*/ return dataset; }
From source file:GraphicsUtil.java
static public void drawArrow(Graphics g, int x0, int y0, int x1, int y1, int headLength, int headAngle) { double offs = headAngle * Math.PI / 180.0; double angle = Math.atan2(y0 - y1, x0 - x1); int[] xs = { x1 + (int) (headLength * Math.cos(angle + offs)), x1, x1 + (int) (headLength * Math.cos(angle - offs)) }; int[] ys = { y1 + (int) (headLength * Math.sin(angle + offs)), y1, y1 + (int) (headLength * Math.sin(angle - offs)) }; g.drawLine(x0, y0, x1, y1);//from w w w . j a v a2 s .com g.drawPolyline(xs, ys, 3); }
From source file:net.ajaskey.market.ta.methods.RegressionOutput.java
/** * This method serves as a constructor for the class. * * @param regressionMethods/*from w ww . j a v a 2 s. com*/ * * @param parameters * @param varcov * @param isSymmetricCompressed * @param nobs * @param rank * @param sumy * @param sumysq * @param sse * @param containsConstant * @param copyData */ public RegressionOutput(RegressionMethods reg, long days) { this.results = reg.regress(); this.count = this.results.getN(); this.predictedPrice = reg.predict(days); this.meanErr = Math.sqrt(this.results.getMeanSquareError()); this.slope = (reg.getSlope() * 180.0) / Math.PI; this.r2 = this.results.getRSquared(); }
From source file:Main.java
static double distanceFromArc(double dA, double dB, double dAB) { // In spherical trinagle ABC // a is length of arc BC, that is dB // b is length of arc AC, that is dA // c is length of arc AB, that is dAB // We rename parameters so following formulas are more clear: double a = dB; double b = dA; double c = dAB; // First, we calculate angles alpha and beta in spherical triangle ABC // and based on them we decide how to calculate the distance: if (Math.sin(b) * Math.sin(c) == 0.0 || Math.sin(c) * Math.sin(a) == 0.0) { // It probably means that one of distance is n*pi, which gives around 20000km for n = 1, // unlikely for Denmark, so we should be fine. return -1.0; }/*from w w w .ja va 2s.c o m*/ double alpha = Math.acos((Math.cos(a) - Math.cos(b) * Math.cos(c)) / (Math.sin(b) * Math.sin(c))); double beta = Math.acos((Math.cos(b) - Math.cos(c) * Math.cos(a)) / (Math.sin(c) * Math.sin(a))); // It is possible that both sinuses are too small so we can get nan when dividing with them if (Double.isNaN(alpha) || Double.isNaN(beta)) { // double cosa = cos(a); // double cosbc = cos(b) * cos(c); // double minus1 = cosa - cosbc; // double sinbc = sin(b) * sin(c); // double div1 = minus1 / sinbc; // // double cosb = cos(b); // double cosca = cos(a) * cos(c); // double minus2 = cosb - cosca; // double sinca = sin(a) * sin(c); // double div2 = minus2 / sinca; return -1.0; } // If alpha or beta are zero or pi, it means that C is on the same circle as arc AB, // we just need to figure out if it is between AB: if (alpha == 0.0 || beta == 0.0) { return (dA + dB > dAB) ? Math.min(dA, dB) : 0.0; } // If alpha is obtuse and beta is acute angle, then // distance is equal to dA: if (alpha > Math.PI / 2 && beta < Math.PI / 2) return dA; // Analogously, if beta is obtuse and alpha is acute angle, then // distance is equal to dB: if (beta > Math.PI / 2 && alpha < Math.PI / 2) return dB; // If both alpha and beta are acute or both obtuse or one of them (or both) are right, // distance is the height of the spherical triangle ABC: // Again, unlikely, since it would render at least pi/2*EARTH_RADIUS_IN_METERS, which is too much. if (Math.cos(a) == 0.0) return -1; double x = Math.atan(-1.0 / Math.tan(c) + (Math.cos(b) / (Math.cos(a) * Math.sin(c)))); // Similar to previous edge cases... if (Math.cos(x) == 0.0) return -1.0; return Math.acos(Math.cos(a) / Math.cos(x)); }