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:br.prof.salesfilho.oci.service.ImageDescriptorService.java

/**
 * @param signal/*from   w ww . j a va  2  s. co  m*/
 * @param kernel Kernel size
 * @return AutoCorrentropy array
 */
public double[] autoCorrentropy(double[] signal, double kernel) {
    //Normalyze
    //signal = OCIUtils.maxElementArrayNormalyze(signal);

    double twokSizeSquare = 2 * Math.pow(kernel, 2d);
    int signal_length = signal.length;
    double[] autoCorrentropy = new double[signal_length];
    double b = 1 / kernel * Math.sqrt(2 * Math.PI);
    int N = signal_length;

    for (int m = 0; m < signal_length; m++) {
        for (int n = m + 1; n < signal_length; n++) {
            double pow = Math.pow((signal[n] - signal[n - m - 1]), 2);
            double exp = Math.exp(-pow / twokSizeSquare);
            double equation = (1d / (N - m + 1d)) * b * exp;
            autoCorrentropy[m] = autoCorrentropy[m] + equation;
        }
    }
    return autoCorrentropy;
}

From source file:at.uni_salzburg.cs.ros.artificer.LocationData.java

/**
 * @param configuration configuration/* www. j av  a 2s .  c  o m*/
 * @param location location
 */
public LocationData(Configuration configuration, Location location) {
    clock = configuration.getClock();
    this.location = location;
    simDetails = configuration.getLocationSimulationDetails();
    velocity = simDetails.get(location.getLocationId()).getAverageSpeed();
    mutation = simDetails.get(location.getLocationId()).getMutationSpeed();

    minLatitude = simDetails.get(location.getLocationId()).getMinLatitude();
    maxLatitude = simDetails.get(location.getLocationId()).getMaxLatitude();
    minLongitude = simDetails.get(location.getLocationId()).getMinLongitude();
    maxLongitude = simDetails.get(location.getLocationId()).getMaxLongitude();

    moving = Math.abs(velocity) > 1E-6 || Math.abs(mutation) > 1E-4;
    heading = RandomUtils.nextDouble() * 2.0 * Math.PI;
    headingSouth = Math.sin(heading) * velocity;
    headingEast = Math.cos(heading) * velocity;
}

From source file:PrintFromButton.java

public BranchGroup createSceneGraph(Raster drawRaster) {
    // Create the root of the branch graph
    BranchGroup objRoot = new BranchGroup();

    // spin object has composited transformation matrix
    Transform3D spin = new Transform3D();
    Transform3D tempspin = new Transform3D();

    spin.rotX(Math.PI / 4.0d);
    tempspin.rotY(Math.PI / 5.0d);
    spin.mul(tempspin);/*from  w  w  w .  j  a  va 2  s  .co m*/
    spin.setScale(0.7);
    spin.setTranslation(new Vector3d(-0.4, 0.3, 0.0));

    TransformGroup objTrans = new TransformGroup(spin);
    objRoot.addChild(objTrans);

    // Create a simple shape leaf node, add it to the scene graph.
    // ColorCube is a Convenience Utility class
    objTrans.addChild(new ColorCube(0.4));

    //Create a raster obj
    Shape3D shape = new Shape3D(drawRaster);
    objRoot.addChild(shape);

    // Let Java 3D perform optimizations on this scene graph.
    objRoot.compile();

    return objRoot;
}

From source file:com.opengamma.analytics.math.minimization.NonLinearTransformFunctionTest.java

@Test
public void testNullTransform() {
    BitSet fixed = new BitSet();
    fixed.set(0);/*from  www.j ava2  s.c om*/
    DoubleMatrix1D start = new DoubleMatrix1D(new double[] { Math.PI / 4, 1 });
    UncoupledParameterTransforms transforms = new UncoupledParameterTransforms(start, NULL_TRANSFORMS, fixed);
    NonLinearTransformFunction transFunc = new NonLinearTransformFunction(FUNCTION, JACOBIAN, transforms);
    Function1D<DoubleMatrix1D, DoubleMatrix1D> func = transFunc.getFittingFunction();
    Function1D<DoubleMatrix1D, DoubleMatrix2D> jacFunc = transFunc.getFittingJacobian();

    DoubleMatrix1D x = new DoubleMatrix1D(new double[] { 0.5 });
    final double rootHalf = Math.sqrt(0.5);
    DoubleMatrix1D y = func.evaluate(x);
    assertEquals(3, y.getNumberOfElements());
    assertEquals(rootHalf * Math.cos(0.5), y.getEntry(0), 1e-9);
    assertEquals(rootHalf * Math.sin(0.5), y.getEntry(1), 1e-9);
    assertEquals(rootHalf, y.getEntry(2), 1e-9);

    DoubleMatrix2D jac = jacFunc.evaluate(x);
    assertEquals(3, jac.getNumberOfRows());
    assertEquals(1, jac.getNumberOfColumns());
    assertEquals(-rootHalf * Math.sin(0.5), jac.getEntry(0, 0), 1e-9);
    assertEquals(rootHalf * Math.cos(0.5), jac.getEntry(1, 0), 1e-9);
    assertEquals(0, jac.getEntry(2, 0), 1e-9);
}

From source file:Controlador.ChartServlet.java

public JFreeChart getChart() throws URISyntaxException {

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    Equipos eq = new Equipos();
    Equipo e = eq.buscar(1);//  w w w .  ja  va2s.c om
    dataset.addValue(e.getNumSerie(), String.copyValueOf(e.getNombre()), " 1");

    JFreeChart chart = ChartFactory.createBarChart3D("3D Bar Chart Demo", // chart title
            "equipo", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    CategoryPlot plot = chart.getCategoryPlot();
    CategoryAxis axis = plot.getDomainAxis();
    axis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 8.0));

    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setItemLabelsVisible(true);
    BarRenderer r = (BarRenderer) renderer;
    r.setMaximumBarWidth(0.05);
    return chart;

}

From source file:fsm.series.Series_CF.java

public double getF2Value(double y, int m, int n) {
    double Pi = Math.PI;

    double um = getMu_m(m);
    double un = getMu_m(n);
    double alphaM = (sin(um) + sinh(um)) / (cos(um) + cosh(um));

    double alphaN = (sin(un) + sinh(un)) / (cos(un) + cosh(un));
    double km = um / a;
    double kn = un / a;

    BigDecimal Ymd2;//from w  w w  . java 2s .  c  om
    BigDecimal Yn;

    BigDecimal cosh = new BigDecimal(alphaM * km * km * cosh(km * y));

    BigDecimal sinh = new BigDecimal(-km * km * sinh(km * y));
    BigDecimal sin = new BigDecimal(-km * km * sin(km * y));
    BigDecimal cos = new BigDecimal(alphaM * km * km * cos(km * y));

    Ymd2 = (cos.add(sin).add(sinh).add(cosh));

    BigDecimal coshN = new BigDecimal(-alphaN * -cosh(kn * y));
    BigDecimal sinhN = new BigDecimal(-sinh(kn * y));
    BigDecimal sinN = new BigDecimal(sin(kn * y));
    BigDecimal cosN = new BigDecimal(-alphaN * cos(kn * y));

    Yn = cosN.add(sinN).add(sinhN).add(coshN);

    BigDecimal ans = Ymd2.multiply(Yn);

    return ans.doubleValue();
}

From source file:gchisto.gui.panels.gcstats.BreakdownChartPanelMulti.java

/**
 * It creates a chart for the given dataset and adds the chart to the panel.
 *
 * @param dataset The dataset that will provide the values for the chart.
 *//*from w  ww  .  j  av a 2 s.  co m*/
private void addChart() {
    JFreeChart chart = ChartFactory.createStackedBarChart3D(getTitle(), null, "Breakdown" + unitSuffix(),
            dataset, PlotOrientation.VERTICAL, true, true, false);
    CategoryAxis domainAxis = chart.getCategoryPlot().getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
    chart.addProgressListener(locker);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setToolTipGenerator(dataset);

    mainPanel().add(BorderLayout.CENTER, new ChartPanel(chart));
}

From source file:SimpleCylinder.java

/**
 * This builds the content branch of our scene graph. It uses the Cylinder
 * utility class to create the actual shape, adding to to the transform
 * group so that the shape is slightly tilted to reveal its 3D shape.
 * /*  w w  w. java 2 s.c  o m*/
 * @param shape
 *            Node that represents the geometry for the content
 * @return BranchGroup that is the root of the content branch
 */
protected BranchGroup buildContentBranch() {
    BranchGroup contentBranch = new BranchGroup();
    Transform3D rotateCube = new Transform3D();
    rotateCube.set(new AxisAngle4d(1.0, 1.0, 0.0, Math.PI / 4.0));
    TransformGroup rotationGroup = new TransformGroup(rotateCube);
    contentBranch.addChild(rotationGroup);
    //Create the shape and add it to the branch
    rotationGroup.addChild(new Cylinder(1.0f, 1.0f, new Appearance()));
    return contentBranch;
}

From source file:etomica.math.SpecialFunctions.java

public static double gamma(double x) {
    if (x == 0) {
        return 1;
    }//from  w w  w  . j  av a2s  .co m
    if (x < 0.5) {
        return Math.PI / (Math.sin(Math.PI * x) * gamma(1 - x));
    }
    double y = Math.exp(lnGamma(x));
    return y;
}

From source file:SimpleCone.java

/**
 * This builds the content branch of our scene graph. It uses the buildShape
 * function to create the actual shape, adding to to the transform group so
 * that the shape is slightly tilted to reveal its 3D shape.
 * /*  w w w  . ja  v  a 2  s . 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() {
    BranchGroup contentBranch = new BranchGroup();
    Transform3D rotateCube = new Transform3D();
    rotateCube.set(new AxisAngle4d(1.0, 1.0, 0.0, Math.PI / 4.0));
    TransformGroup rotationGroup = new TransformGroup(rotateCube);
    contentBranch.addChild(rotationGroup);
    rotationGroup.addChild(new Cone(1.0f, 2.0f, 0, new Appearance()));
    return contentBranch;
}