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:org.jfree.chart.demo.CombinedXYPlotDemo1.java
/** * Creates a combined chart.//w w w . j av a2 s. c om * * @return the combined chart. */ private JFreeChart createCombinedChart() { // create subplot 1... final XYDataset data1 = createDataset1(); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("Range 1"); final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); final XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation.setRotationAngle(Math.PI / 4.0); subplot1.addAnnotation(annotation); // create subplot 2... final XYDataset data2 = createDataset2(); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis("Range 2"); rangeAxis2.setAutoRangeIncludesZero(false); final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot... return new JFreeChart("CombinedDomainXYPlot Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:com.wheelermarine.publicAccessSites.Updater.java
/** * Convert a UTM location to a latitude and longitude location. * * @param north the northing value./* ww w. ja v a2 s . c o 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:electrical_parameters.Carson.java
public Carson(RealMatrix Dik, RealMatrix Dik_mirror, RealMatrix Fik, double[] hx2, ArrayList<elpam_input_conductor> cnd_list, boolean exact_GMR, boolean exact_Rac, int fv, int gw) { // GMR_calculation cnd = new GMR_calculation(Conductor); // Rac_calculation cnd2 = new Rac_calculation(Conductor); this.GMR = new double[cnd_list.size()]; this.hx2 = new double[cnd_list.size()]; this.R = new double[cnd_list.size()]; this.GMR = new double[cnd_list.size()]; this.rho_gnd = new double[cnd_list.size()]; this.f = constants.getFrequency(); this.omega = (double) 2 * Math.PI * this.f; this.fv = fv; this.gw = gw; if (exact_GMR) { for (int i = 0; i < cnd_list.size(); i++) { this.GMR[i] = cnd_list.get(i).getGMR(); }/*w ww.jav a 2 s . c o m*/ } else { for (int i = 0; i < cnd_list.size(); i++) { this.GMR[i] = cnd_list.get(i).getGMR_default(); } } if (exact_Rac) { for (int i = 0; i < cnd_list.size(); i++) { this.R[i] = cnd_list.get(i).getRac(); } } else { for (int i = 0; i < cnd_list.size(); i++) { this.R[i] = cnd_list.get(i).getRdc(); } } this.Dik = Dik; this.Dik_mirror = Dik_mirror; this.Fik = Fik; this.hx2 = hx2; for (int i = 0; i < cnd_list.size(); i++) { this.rho_gnd[i] = cnd_list.get(i).getRho_ground(); } this.Rg = initMatrix(Dik); this.Lg = initMatrix(Dik); this.Xg = initMatrix(Dik); this.L_no_gnd = initMatrix(Dik); this.X_no_gnd = initMatrix(Dik); this.R_no_gnd = initMatrix(Dik); this.R_gnd = initMatrix(Dik); this.L_gnd = initMatrix(Dik); this.X_gnd = initMatrix(Dik); this.Z_gnd = initComplexMatrix(Dik); this.Z_no_gnd = initComplexMatrix(Dik); this.R_red_gnd = new Array2DRowRealMatrix(fv, fv); this.L_red_gnd = new Array2DRowRealMatrix(fv, fv); this.X_red_gnd = new Array2DRowRealMatrix(fv, fv); this.Z_red_gnd = new ComplexMatrix(fv, fv); this.R_red_no_gnd = new Array2DRowRealMatrix(fv, fv); this.L_red_no_gnd = new Array2DRowRealMatrix(fv, fv); this.X_red_no_gnd = new Array2DRowRealMatrix(fv, fv); this.Z_red_no_gnd = new ComplexMatrix(fv, fv); this.L_red_gnd_symm = new Array2DRowRealMatrix(fv, fv); this.R_red_gnd_symm = new Array2DRowRealMatrix(fv, fv); this.X_red_gnd_symm = new Array2DRowRealMatrix(fv, fv); this.Z_red_gnd_symm = new ComplexMatrix(fv, fv); this.L_red_no_gnd_symm = new Array2DRowRealMatrix(fv, fv); this.R_red_no_gnd_symm = new Array2DRowRealMatrix(fv, fv); this.X_red_no_gnd_symm = new Array2DRowRealMatrix(fv, fv); this.Z_red_no_gnd_symm = new ComplexMatrix(fv, fv); }
From source file:fr.ritaly.dungeonmaster.Utils.java
public static double angle(Direction direction, int x1, int y1, int x2, int y2) { final double angle = angle(x1, y1, x2, y2); switch (direction) { case NORTH://from w w w.ja v a 2s. c o m return (Math.PI / 2) - angle; case EAST: return angle; case WEST: return (Math.PI) + angle; case SOUTH: return (3 * Math.PI / 2) - angle; default: throw new UnsupportedOperationException(); } }
From source file:com.alvermont.terraj.stargen.EnviroUtils.java
/** * Get the radius of the volume for a specified mass * * @param mass The mass (in units of solar masses) * @param density The density (in grams/cc) * @return The orbital radius in km//from w w w . j a v a 2s. c om */ public static double getVolumeRadius(double mass, double density) { final double massG = mass * Constants.SOLAR_MASS_IN_GRAMS; final double volume = massG / density; return (Math.pow((3.0 * volume) / (4.0 * Math.PI), (1.0 / 3.0)) / Constants.CM_PER_KM); }
From source file:electrical_parameters.CarsonModified.java
public CarsonModified(RealMatrix Dik, RealMatrix Dik_mirror, RealMatrix Fik, double[] hx2, ArrayList<elpam_input_conductor> cnd_list, boolean exact_GMR, boolean exact_Rac, int fv, int gw) { // GMR_calculation cnd = new GMR_calculation(Conductor); // Rac_calculation cnd2 = new Rac_calculation(Conductor); this.GMR = new double[cnd_list.size()]; this.hx2 = new double[cnd_list.size()]; this.R = new double[cnd_list.size()]; this.GMR = new double[cnd_list.size()]; this.rho_gnd = new double[cnd_list.size()]; this.f = constants.getFrequency(); this.omega = (double) 2 * Math.PI * this.f; this.fv = fv; this.gw = gw; if (exact_GMR) { for (int i = 0; i < cnd_list.size(); i++) { this.GMR[i] = cnd_list.get(i).getGMR(); }// w ww . ja v a 2 s .c o m } else { for (int i = 0; i < cnd_list.size(); i++) { this.GMR[i] = cnd_list.get(i).getGMR_default(); } } if (exact_Rac) { for (int i = 0; i < cnd_list.size(); i++) { this.R[i] = cnd_list.get(i).getRac(); } } else { for (int i = 0; i < cnd_list.size(); i++) { this.R[i] = cnd_list.get(i).getRdc(); } } this.Dik = Dik; this.Dik_mirror = Dik_mirror; this.Fik = Fik; this.hx2 = hx2; for (int i = 0; i < cnd_list.size(); i++) { this.rho_gnd[i] = cnd_list.get(i).getRho_ground(); } this.Rg = initMatrix(Dik); this.Lg = initMatrix(Dik); this.Xg = initMatrix(Dik); this.L_no_gnd = initMatrix(Dik); this.X_no_gnd = initMatrix(Dik); this.R_no_gnd = initMatrix(Dik); this.R_gnd = initMatrix(Dik); this.L_gnd = initMatrix(Dik); this.X_gnd = initMatrix(Dik); this.Z_gnd = initComplexMatrix(Dik); this.Z_no_gnd = initComplexMatrix(Dik); this.R_red_gnd = new Array2DRowRealMatrix(fv, fv); this.L_red_gnd = new Array2DRowRealMatrix(fv, fv); this.X_red_gnd = new Array2DRowRealMatrix(fv, fv); this.Z_red_gnd = new ComplexMatrix(fv, fv); this.R_red_no_gnd = new Array2DRowRealMatrix(fv, fv); this.L_red_no_gnd = new Array2DRowRealMatrix(fv, fv); this.X_red_no_gnd = new Array2DRowRealMatrix(fv, fv); this.Z_red_no_gnd = new ComplexMatrix(fv, fv); this.L_red_gnd_symm = new Array2DRowRealMatrix(fv, fv); this.R_red_gnd_symm = new Array2DRowRealMatrix(fv, fv); this.X_red_gnd_symm = new Array2DRowRealMatrix(fv, fv); this.Z_red_gnd_symm = new ComplexMatrix(fv, fv); this.L_red_no_gnd_symm = new Array2DRowRealMatrix(fv, fv); this.R_red_no_gnd_symm = new Array2DRowRealMatrix(fv, fv); this.X_red_no_gnd_symm = new Array2DRowRealMatrix(fv, fv); this.Z_red_no_gnd_symm = new ComplexMatrix(fv, fv); }
From source file:edu.duke.cs.osprey.ematrix.epic.GaussianLowEnergySampler.java
private double chooseNumSigmas() { //The good region will extend to roughly //this many sigmas in each dimension double insideTarget = 0.25;//how much of the multivariate distr should be in the "good zone" //underestimate since we can always reject to make up for uncertainty //OK zt will be the value of z = sum_i x_i^2 / 2sigma_i^2 //such that integrating the probability of a Gaussian over the z>zt zone = insideTarget //This will tell us at what zt to place our threshold points //WLOG we do this integration with a standard normal distribution in numDOFs dimensions //we need consider only the radial integral: //\int_0^a exp(-r^2/2) r^(numDOFs-1) dr //then insideTarget = radialIntegral(0 to sqrt(2*zt)) / radialIntegral(0 to infty) double fullInteg = 1;//radial integral from 0 to infty if (numDOFs % 2 == 1) fullInteg = Math.sqrt(Math.PI / 2); for (int k = numDOFs - 2; k > 0; k -= 2) fullInteg *= k;/*from w w w . j a va 2s . com*/ //we find the right sqrt(2*zt) by bisection double target = fullInteg * insideTarget;//value we want radial integral to achieve double epsilon = 0.02; double lo = 0;//initial lower bound on sqrt(2*zt) double hi = 1;//upper bound while (radialIntegral(hi, numDOFs - 1) < target) hi *= 2; do { double mid = (hi + lo) / 2; double midVal = radialIntegral(mid, numDOFs - 1); if (midVal < target) lo = mid; else hi = mid; } while (Math.abs(hi - lo) > epsilon * Math.abs(hi)); //OK so (hi+lo)/2 is now a good estimate of sqrt(2*zt) double numSigmas = (hi + lo) / 2; //Iff the point where the i-axis crosses thresh is y_i, then //sigma_i = y_i/sqrt(2*zt), so we set numSigmas = est(sqrt(2*zt)) = (hi+lo)/2 return numSigmas; }
From source file:SimpleWorld.java
/** * This builds the content branch of our scene graph. It uses the buildCube * function to create the actual shape, adding to to the transform group so * that the shape is slightly tilted to reveal its 3D shape. * /* www. j a v a2s .c om*/ * @param shape * Node that represents the geometry for the content * @return BranchGroup that is the root of the content branch */ protected BranchGroup buildContentBranch(Node shape) { //Create the branch group that will be the root of the content branch BranchGroup contentBranch = new BranchGroup(); //Create the transform that will cause the shape to appear tilted Transform3D rotateCube = new Transform3D(); rotateCube.set(new AxisAngle4d(1.0, 1.0, 0.0, Math.PI / 4.0)); TransformGroup rotationGroup = new TransformGroup(rotateCube); //Put the branch together contentBranch.addChild(rotationGroup); rotationGroup.addChild(shape); return contentBranch; }
From source file:org.squale.squaleweb.util.graph.BarMaker.java
/** * @return le diagramme JFreeChart//w ww . ja v a 2 s . com */ protected JFreeChart getChart() { JFreeChart retChart = super.getChart(); if (null == retChart) { retChart = ChartFactory.createBarChart3D(mTitle, mXLabel, mYLabel, mDataSet, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = retChart.getCategoryPlot(); // Les valeurs sont des entiers final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // On effectue une rotation de 90 pour afficher le titre des abscisses la verticale CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0)); super.setChart(retChart); } return retChart; }
From source file:net.sf.dsp4j.octave.packages.signal_1_2_0.NCauer.java
public NCauer(double Rp, double Rs, int n) { // Cutoff frequency = 1: double wp = 1; // Stop band edge ws: double ws = __ellip_ws(n, Rp, Rs); double k = wp / ws; double k1 = Math.sqrt(1.0 - Math.pow(k, 2)); double q0 = (1.0 / 2.0) * ((1.0 - Math.sqrt(k1)) / (1 + Math.sqrt(k1))); double q = q0 + 2.0 * Math.pow(q0, 5) + 15.0 * Math.pow(q0, 9) + 150.0 * Math.pow(q0, 13); //%(....) double D = (Math.pow(10, 0.1 * Rs) - 1.0) / (Math.pow(10, (0.1 * Rp)) - 1.0); //Filter order maybe this, but not used now: //n=ceil(log10(16*D)/log10(1/q)) double l = (1.0 / (2.0 * n)) * Math.log((Math.pow(10, 0.05 * Rp) + 1.0) / (Math.pow(10, 0.05 * Rp) - 1.0)); double sig01 = 0; double sig02 = 0; for (int m = 0; m <= 30; m++) { sig01 = sig01 + Math.pow((-1), m) * Math.pow(q, (m * (m + 1))) * Math.sinh((2 * m + 1) * l); }// w w w .j a v a2 s.c om for (int m = 1; m <= 30; m++) { sig02 = sig02 + Math.pow(-1.0, m) * Math.pow(q, (Math.pow(m, 2))) * Math.cosh(2 * m * l); } double sig0 = Math.abs((2.0 * Math.pow(q, (1.0 / 4.0)) * sig01) / (1.0 + 2.0 * sig02)); double w = Math.sqrt((1.0 + k * Math.pow(sig0, 2)) * (1.0 + Math.pow(sig0, 2) / k)); int r; if (n % 2 != 0) { r = (n - 1) / 2; } else { r = n / 2; } double[] wi = new double[r]; for (int ii = 1; ii <= r; ii++) { double mu; if (n % 2 != 0) { mu = ii; } else { mu = (double) ii - 0.5; } double soma1 = 0; for (int m = 0; m <= 30; m++) { soma1 = soma1 + 2.0 * Math.pow(q, (1.0 / 4.0)) * (Math.pow(-1.0, m) * Math.pow(q, (m * (m + 1))) * Math.sin(((2.0 * m + 1.0) * Math.PI * mu) / n)); } double soma2 = 0; for (int m = 1; m <= 30; m++) { soma2 = soma2 + 2.0 * (Math.pow(-1.0, m) * Math.pow(q, (Math.pow(m, 2))) * Math.cos((2.0 * m * Math.PI * mu) / n)); } wi[ii - 1] = (soma1 / (1.0 + soma2)); } double[] Vi = new double[wi.length]; for (int i = 0; i < wi.length; i++) { Vi[i] = Math.sqrt((1.0 - (k * (Math.pow(wi[i], 2)))) * (1.0 - (Math.pow(wi[i], 2)) / k)); } double[] A0i = new double[wi.length]; for (int i = 0; i < wi.length; i++) { A0i[i] = 1.0 / (Math.pow(wi[i], 2)); } double[] sqrA0i = new double[wi.length]; for (int i = 0; i < wi.length; i++) { sqrA0i[i] = 1.0 / wi[i]; } double[] B0i = new double[wi.length]; for (int i = 0; i < wi.length; i++) { B0i[i] = (Math.pow((sig0 * Vi[i]), 2) + Math.pow((w * wi[i]), 2)) / Math.pow((1.0 + Math.pow(sig0, 2) * Math.pow(wi[i], 2)), 2); } double C01; if (wi.length == 0) { C01 = 1.0; } else { C01 = B0i[0] / A0i[0]; for (int i = 1; i < wi.length; i++) { C01 *= B0i[i] / A0i[i]; } } //Gain T0: if (n % 2 != 0) { T0 = sig0 * C01 * Math.sqrt(ws); } else { T0 = Math.pow(10, (-0.05 * Rp)) * C01; } //zeros: zer = new Complex[sqrA0i.length * 2]; for (int i = 0; i < sqrA0i.length; i++) { zer[i] = Complex.valueOf(0.0, sqrA0i[i]); zer[i + sqrA0i.length] = Complex.valueOf(0.0, -sqrA0i[i]); } //poles: pol = new Complex[Vi.length * 2]; for (int i = 0; i < Vi.length; i++) { pol[i] = new Complex(-2.0 * sig0 * Vi[i], 2.0 * wi[i] * w) .divide(2.0 * (1 + Math.pow(sig0, 2) * Math.pow(wi[i], 2))); pol[i + Vi.length] = new Complex(-2.0 * sig0 * Vi[i], -2.0 * wi[i] * w) .divide(2.0 * (1 + Math.pow(sig0, 2) * Math.pow(wi[i], 2))); } //If n odd, there is a real pole -sig0: if (n % 2 != 0) { pol = Arrays.copyOf(pol, pol.length + 1); pol[pol.length - 1] = new Complex(-sig0); } for (int i = 0; i < pol.length; i++) { pol[i] = pol[i].multiply(Math.sqrt(ws)); } for (int i = 0; i < zer.length; i++) { zer[i] = zer[i].multiply(Math.sqrt(ws)); } }