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:eu.amidst.core.exponentialfamily.EF_JointNormalGamma.java
/** * {@inheritDoc}/* w ww . j av a 2s . c o m*/ */ @Override public double computeLogBaseMeasure(double val) { return -0.5 * Math.log(2 * Math.PI); }
From source file:es.udc.gii.common.eaf.benchmark.multiobjective.wfg.Wfg_Objective.java
protected double convex(double[] x, int m, int M) { int i;/*from w ww . j a v a2 s. c o m*/ double result = 1.0; for (i = 1; i <= M - m; i++) { result *= 1.0 - Math.cos(x[i - 1] * Math.PI / 2.0); } if (m != 1) { result *= 1.0 - Math.sin(x[M - m] * Math.PI / 2.0); } return correct_to_01(result, EPSILON); }
From source file:com.opengamma.analytics.financial.model.option.pricing.fourier.FourierPricer.java
public double price(final BlackFunctionData data, final EuropeanVanillaOption option, final MartingaleCharacteristicExponent ce, final double alpha, final double limitTolerance, final boolean useVarianceReduction) { Validate.notNull(data, "data"); Validate.notNull(option, "option"); Validate.notNull(ce, "characteristic exponent"); Validate.isTrue(limitTolerance > 0, "limit tolerance must be > 0"); Validate.isTrue(alpha <= ce.getLargestAlpha() && alpha >= ce.getSmallestAlpha(), "The value of alpha is not valid for the Characteristic Exponent and will most likely lead to mispricing. Choose a value between " + ce.getSmallestAlpha() + " and " + ce.getLargestAlpha()); final EuropeanPriceIntegrand integrand = new EuropeanPriceIntegrand(ce, alpha, useVarianceReduction); final EuropeanCallFourierTransform psi = new EuropeanCallFourierTransform(ce); final double strike = option.getStrike(); final double t = option.getTimeToExpiry(); final boolean isCall = option.isCall(); final double forward = data.getForward(); final double discountFactor = data.getDiscountFactor(); final Function1D<ComplexNumber, ComplexNumber> characteristicFunction = psi.getFunction(t); final double xMax = LIMIT_CALCULATOR.solve(characteristicFunction, alpha, limitTolerance); final Function1D<Double, Double> func = integrand.getFunction(data, option); final double integral = Math.exp(-alpha * Math.log(strike / forward)) * _integrator.integrate(func, 0.0, xMax) / Math.PI; if (useVarianceReduction) { final double black = BLACK_PRICE_FUNCTION.getPriceFunction(option).evaluate(data); final double diff = discountFactor * forward * integral; return diff + black; }// w w w .j a va 2 s . c o m if (isCall) { if (alpha > 0.0) { return discountFactor * forward * integral; } else if (alpha < -1.0) { return discountFactor * (forward * (1 + integral) - strike); } else { return discountFactor * forward * (integral + 1); } } if (alpha > 0.0) { return discountFactor * (forward * (integral - 1) + strike); } else if (alpha < -1.0) { return discountFactor * forward * integral; } return discountFactor * (forward * integral + strike); }
From source file:Math3D.java
/** * Converts the Matrix into Euler angles (roll, pitch, yaw ) *///from w ww.j a va2 s .c o m public static void toEuler(Matrix3d matrix, Vector3d euler) { Vector3d v3d = new Vector3d(); Vector3d zAxis = new Vector3d(0, 0, -1); Vector3d yAxis = new Vector3d(0, 1, 0); Vector3d xAxis = new Vector3d(1, 0, 0); v3d.set(xAxis); matrix.transform(v3d); v3d.x = Math.abs(v3d.x); v3d.z = 0; v3d.normalize(); euler.x = xAxis.angle(v3d); v3d.set(yAxis); matrix.transform(v3d); v3d.z = Math.abs(v3d.z); v3d.x = 0; v3d.normalize(); euler.y = yAxis.angle(v3d); v3d.set(zAxis); matrix.transform(v3d); v3d.y = 0; v3d.normalize(); euler.z = zAxis.angle(v3d); if (v3d.x < 0) euler.z = 2 * Math.PI - euler.z; }
From source file:net.sf.dsp4j.octave.packages.signal_1_0_11.Freqz.java
public Freqz(double[] b, double[] a, int n) { FastFourierTransformer fft = new FastFourierTransformer(DftNormalization.STANDARD); Complex[] hb = fft.transform(Arrays.copyOf(b, 2 * n), TransformType.FORWARD); Complex[] ha = fft.transform(Arrays.copyOf(a, 2 * n), TransformType.FORWARD); H = new Complex[n]; w = new double[n]; for (int i = 0; i < H.length; i++) { H[i] = hb[i].divide(ha[i]);/*from www . j av a 2 s .co m*/ w[i] = Math.PI / n * i; } }
From source file:edu.stanford.slac.archiverappliance.PB.data.LargePBLineTest.java
@Test public void testLargeLines() throws Exception { // We create vector doubles with a large number of elements; write it out and then test the read. String pvName = ConfigServiceForTests.ARCH_UNIT_TEST_PVNAME_PREFIX + "LargeLineTest" + largeLineTest.getPartitionGranularity(); ArchDBRTypes type = ArchDBRTypes.DBR_WAVEFORM_DOUBLE; short year = TimeUtils.getCurrentYear(); for (int i = 1; i < 7200; i++) { try (BasicContext context = new BasicContext()) { ArrayListEventStream strm = new ArrayListEventStream(1024, new RemotableEventStreamDesc(type, pvName, year)); DBR_TIME_Double retvd = new DBR_TIME_Double(ArrayUtils .toPrimitive(Collections.nCopies(i, Math.sin(i * Math.PI / 3600)).toArray(new Double[0]))); retvd.setTimeStamp(new gov.aps.jca.dbr.TimeStamp(TimeUtils.getStartOfCurrentYearInSeconds() + i)); retvd.setSeverity(1);//w ww.j a v a 2s . c om retvd.setStatus(0); strm.add(new PBVectorDouble(retvd)); largeLineTest.appendData(context, pvName, strm); } catch (Exception ex) { logger.error("Exception appending data " + i, ex); fail(ex.getMessage()); } } Path[] allPaths = PlainPBPathNameUtility.getAllPathsForPV(new ArchPaths(), largeLineTest.getRootFolder(), pvName, ".pb", largeLineTest.getPartitionGranularity(), CompressionMode.NONE, configService.getPVNameToKeyConverter()); assertTrue("testLargeLines returns null for getAllFilesForPV for " + pvName, allPaths != null); assertTrue("testLargeLines returns empty array for getAllFilesForPV for " + pvName, allPaths.length > 0); for (Path destPath : allPaths) { try { PBFileInfo info = new PBFileInfo(destPath); info.getLastEventEpochSeconds(); assertTrue("File validation failed for " + destPath.toAbsolutePath().toString(), ValidatePBFile.validatePBFile(destPath, false)); } catch (Exception ex) { logger.error("Exception parsing file" + destPath.toAbsolutePath().toString(), ex); fail(ex.getMessage()); } } }
From source file:HelloUniverse1.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // Create the TransformGroup node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at run time. Add it to // the root of the subgraph. TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objTrans);/*from w w w. j a v a 2s . co m*/ // Create a simple Shape3D node; add it to the scene graph. objTrans.addChild(new ColorCube(0.4)); // Create a new Behavior object that will perform the // desired operation on the specified transform and add // it into the scene graph. Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, 4000); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI * 2.0f); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); rotator.setSchedulingBounds(bounds); objRoot.addChild(rotator); // Have Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:etomica.virial.MCMoveClusterRingRegrowOrientation.java
/** * Set PI harmonic spring stiffness for given temperature and atomic mass. * Dimer is assumed to be composed of two atoms of the given mass. *//* w w w .j a v a 2s . c om*/ public void setStiffness(double t, double mass) { double lambda = Constants.PLANCK_H / (Math.sqrt(2 * Math.PI * mass * t)); kHarmonic = Math.PI * P / (lambda * lambda); // System.out.println("Stiffness = "+stiffness); }
From source file:PureImmediate.java
public void render() { if (gc == null) { // Set up Graphics context gc = canvas.getGraphicsContext3D(); gc.setAppearance(new Appearance()); // Set up geometry cube = new ColorCube(0.4).getGeometry(); }// w w w .j av a 2s.c o m // Compute angle of rotation based on alpha value double angle = rotAlpha.value() * 2.0 * Math.PI; cmt.rotY(angle); // Render the geometry for this frame gc.clear(); gc.setModelTransform(cmt); gc.draw(cube); canvas.swap(); }
From source file:BackEnd.B_calculation.java
private FazorVektor calc_DB(DPoint Rp, DPoint R0, DPoint deltaL) throws DelaunayError { DPoint R_0 = new DPoint(R0.getX(), R0.getY(), R0.getZ()); R_0.setY(R0.getY() + R0_bundleY); // bundle korektura pre jeden druhy SMER // treba to priemetovat R_0.setZ(R0.getZ() + Math.cos(beta) * R0_bundleZ); // priemety R_0.setX(R0.getX() + Math.sin(beta) * R0_bundleZ); // System.out.println( "R_0= " + R_0 ); // System.out.println( "Rp= " + Rp ); ////w ww. j a va2s. c o m // System.out.println( "deltal= " + deltaL ); double K = (this.mu0 * this.muR) / (4 * Math.PI); // kontanta DPoint R = help.substract(Rp, R_0); // rozdiel vektorov double menovatel = Math.pow(get_ABS(R), 3); FazorVektor deltaB = new FazorVektor(new Complex(0, 0), new Complex(0, 0), new Complex(0, 0)); DPoint C = vektor_sucin(deltaL, R); deltaB.setX_Real(K * ((getI_real() * C.getX()) / menovatel)); deltaB.setY_Real(K * ((getI_real() * C.getY()) / menovatel)); deltaB.setZ_Real(K * ((getI_real() * C.getZ()) / menovatel)); deltaB.setX_Imaginary(K * ((getI_image() * C.getX()) / menovatel)); deltaB.setY_Imaginary(K * ((getI_image() * C.getY()) / menovatel)); deltaB.setZ_Imaginary(K * ((getI_image() * C.getZ()) / menovatel)); return deltaB; }