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:de.termininistic.serein.examples.benchmarks.functions.multimodal.LevyFunction.java
@Override public double map(RealVector v) { double[] x = v.toArray(); double sum = Math.pow(Math.sin(Math.PI * w(x[0])), 2); for (int i = 0; i < x.length - 1; i++) { sum += Math.pow((w(x[i]) - 1), 2) * (1 + 10 * Math.pow(Math.sin(2 * Math.PI * w(x[0]) + 1), 2) + Math.pow(w(x[x.length - 1]) - 1, 2) * (1 + Math.pow(Math.sin(2 * Math.PI * w(x[x.length - 1]) + 1), 2))); }// w w w .j a va 2s .c om return sum; }
From source file:fr.ign.cogit.simplu3d.test.rjmcmc.cuboid.transformation.birth.TransformToSurfaceTest.java
@Before public void setUp() throws Exception { IPolygon polygon = (IPolygon) WktGeOxygene .makeGeOxygene("POLYGON (( 5 0, 5 -10, 15 -10, 15 -5, 10 -5, 10 0, 5 0 ))"); double[] d = new double[] { 0, 0, 1, 1, 3, 0 }; double[] v = new double[] { 10, 10, 5, 5, 3, Math.PI }; t = new TransformToSurface(d, v, polygon); }
From source file:com.mapr.synth.drive.Producer.java
@Override public void run() { Random rand = new Random(3); GeoPoint start = new GeoPoint((rand.nextDouble() - 0.5) * Math.PI / 2, rand.nextDouble() * Math.PI * 2); final Vector3D east = start.east(); final Vector3D north = start.north(east); GeoPoint end = new GeoPoint(start.as3D().add(east.scalarMultiply(-12.0 / Constants.EARTH_RADIUS_KM)) .add(north.scalarMultiply(7.0 / Constants.EARTH_RADIUS_KM))); Vector3D zz = project(east, north, end.as3D()); System.out.printf("==> %.2f %.2f\n", zz.getX(), zz.getY()); while (true) { double t = 0; final Car car = new Car(); System.out.printf("%.2f\n", start.distance(end)); car.driveTo(rand, t, start, end, new Car.Callback() { @Override/*www . jav a 2 s .co m*/ void call(double t, Engine eng, GeoPoint position) { final Vector3D here = project(east, north, position.as3D()); try { output.put(new Trails.State(new Engine(eng), here)); } catch (InterruptedException e) { throw new RuntimeException("Interrupted", e); } } }); } }
From source file:com.deicos.lince.components.SinChartComponent.java
public SinChartComponent() { NumberAxis xAxis = new NumberAxis(); xAxis.setLabel("x"); NumberAxis yAxis = new NumberAxis(); yAxis.setLabel("y"); XYChart.Series<Number, Number> series = new XYChart.Series<>(); series.setName("Sine"); ObservableList<XYChart.Data<Number, Number>> data = series.getData(); for (double x = -Math.PI; x < Math.PI; x += 0.5) { data.add(new XYChart.Data<Number, Number>(x, 10 * Math.sin(x))); }//from w w w . j a va 2 s. c o m LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis); lineChart.setTitle("Sine function"); lineChart.getData().add(series); getChildren().add(lineChart); }
From source file:edu.ucsf.valelab.saim.calculations.SaimCalc.java
/** * Calculates the phase difference as a function of height as described in: * Paszek, M.J., C.C. DuFort, M.G. Rubashkin, M.W. Davidson, K.S. Thorn, J.T. * Liphardt, and V.M. Weaver. 2012. /*from ww w.j ava 2s .c om*/ * Scanning angle interference microscopy reveals cell dynamics at the nanoscale. * Nat Meth. 9:825827. doi:10.1038/nmeth.2077. * * @param wavelength of the excitation light source in nm * @param nSample refractive index of the sample medium * @param angle Angle with respect to the normal in the sample in radians * @param axialPos Position in the sample above the silicon oxide (in nm) * @return phase difference (dimensionless) */ public static double PhaseDiff(final double wavelength, final double angle, final double nSample, final double axialPos) { return 4.0 * Math.PI * nSample * axialPos * Math.cos(angle) / wavelength; }
From source file:demo.components.SinChartComponent.java
public SinChartComponent() { NumberAxis xAxis = new NumberAxis(); xAxis.setLabel("x"); NumberAxis yAxis = new NumberAxis(); yAxis.setLabel("y"); XYChart.Series<Number, Number> series = new XYChart.Series<>(); series.setName("Sine"); ObservableList<XYChart.Data<Number, Number>> data = series.getData(); for (double x = -Math.PI; x < Math.PI; x += 0.5) { data.add(new XYChart.Data<Number, Number>(x, 10 * Math.sin(x))); }//from w ww . j av a2 s . c om LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis); lineChart.setTitle("Sine function"); lineChart.getData().add(series); getChildren().add(lineChart); }
From source file:com.offbynull.peernetic.debug.visualizer.VisualizerUtils.java
/** * Creates point on a circle./*from w ww . j a v a 2 s .c o m*/ * @param radius radius of circle * @param percentage 0 to 1 percentage of where point is on circle -- 0.0 indicates that the point is at the top middle * @return new point on circle specified by {@code radius} and {@code percentage} * @throws IllegalArgumentException if {@code radius} is negative or a special double value (e.g. NaN/infinite/etc..), or if * {@code percentage} isn't between {@code 0.0 - 1.0} */ public static Point pointOnCircle(double radius, double percentage) { Validate.inclusiveBetween(0.0, Double.MAX_VALUE, radius); Validate.inclusiveBetween(0.0, 1.0, percentage); double angle = percentage * Math.PI * 2.0; angle -= Math.PI / 2.0; // adjust so that percentage 0.0 is at top middle, if not it'ld be at middle right double y = (Math.sin(angle) * radius) + radius; // NOPMD double x = (Math.cos(angle) * radius) + radius; // NOPMD return new Point((int) x, (int) y); }
From source file:Rotation.java
/** * Erstellt den Szenegraphen//from w w w. j a v a 2 s . co m * * @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); TransformGroup objDreh = new TransformGroup(drehung); TransformGroup spin = new TransformGroup(); spin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); spin.addChild(new ColorCube(0.4)); objDreh.addChild(spin); objWurzel.addChild(objDreh); // Drehung Alpha spinAlpha = new Alpha(-1, 5000); RotationInterpolator dreher = new RotationInterpolator(spinAlpha, spin); BoundingSphere zone = new BoundingSphere(); dreher.setSchedulingBounds(zone); spin.addChild(dreher); return objWurzel; }
From source file:Erscheinungsbild.java
/** * Erstellt den Szenegraphen//ww w. j a va 2s. c o m * * @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); TransformGroup objDreh = new TransformGroup(drehung); objDreh.addChild(new Box(0.5f, 0.5f, 0.5f, makeAppearance())); objWurzel.addChild(objDreh); return objWurzel; }
From source file:dev.maisentito.suca.commands.EvalCommandHandler.java
@Override public void handleCommand(MessageEvent event, String[] args) throws Throwable { double result = new ExpressionBuilder(StringUtils.join(args, ' ')).variables("pi", "e").build() .setVariable("pi", Math.PI).setVariable("e", Math.E).evaluate(); event.respond("eval: result: " + result); }