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:fuel.gui.stats.BarChartPanel.java

public BarChartPanel(DefaultCategoryDataset barDataset, String message, boolean stacked) {
    JFreeChart barChart;//www  .j a  v  a 2s  . c om
    if (stacked) {
        barChart = ChartFactory.createStackedBarChart3D("", // chart title
                "", // domain axis label
                "", // range axis label
                barDataset, // data
                PlotOrientation.VERTICAL, true, // include legend
                true, // tooltips?
                true // URLs?
        );
    } else {
        barChart = ChartFactory.createBarChart3D("", // chart title
                "", // domain axis label
                "", // range axis label
                barDataset, // data
                PlotOrientation.VERTICAL, false, // include legend
                true, // tooltips?
                true // URLs?
        );
    }
    CategoryPlot plot = barChart.getCategoryPlot();
    BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    final CategoryAxis domainAxis = plot.getDomainAxis();
    double count = barDataset.getColumnCount();
    double extra = 16 / count;
    domainAxis.setCategoryLabelPositions(
            CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / (2 + extra)));

    ChartPanel barChartPanel = new ChartPanel(barChart);
    barChartPanel.getChartRenderingInfo().setEntityCollection(null);
    barChartPanel.setBorder(BorderFactory.createTitledBorder(message));
    int wider = barDataset.getColumnCount() * 12;
    barChartPanel.setPreferredSize(new java.awt.Dimension(192 + wider, 240));
    barChartPanel.setLayout(new BorderLayout());
    setLayout(new BorderLayout());
    add(barChartPanel);
}

From source file:com.wwidesigner.geometry.calculation.DefaultFippleMouthpieceCalculator.java

@Override
protected TransferMatrix calcTransferMatrix(Mouthpiece mouthpiece, double waveNumber,
        PhysicalParameters parameters) {
    if (mouthpiece.isPressureNode()) {
        // Resort to default if this is not a flow-node mouthpiece.
        return super.calcTransferMatrix(mouthpiece, waveNumber, parameters);
    }//from   w ww  .  j av a  2s  .c om
    // Use a simplified version of PhysicalParameters: no editable pressure
    // nor CO2 concentration. This mouthpiece representation gives very
    // wrong answers when they are varied.
    // The SimplePhysicalParameters gives correct answers for varying
    // temperature and humidity, all that a NAF maker is likely to measure.
    mParams = new SimplePhysicalParameters(parameters);

    double radius = 0.5 * mouthpiece.getBoreDiameter();
    double z0 = parameters.calcZ0(radius);
    double omega = waveNumber * parameters.getSpeedOfSound();
    double k_delta_l = calcKDeltaL(mouthpiece, omega, z0);
    // Add a series resistance for radiation loss.
    double r_rad = Tube.calcR(omega / (2 * Math.PI), radius, parameters);
    double cos_kl = FastMath.cos(k_delta_l);
    double sin_kl = FastMath.sin(k_delta_l);

    Complex A = new Complex(cos_kl, r_rad * sin_kl / z0);
    Complex B = new Complex(0., 1.).multiply(sin_kl * z0).add(r_rad * cos_kl);
    Complex C = new Complex(0., 1.).multiply(sin_kl / z0);
    Complex D = new Complex(cos_kl);
    return new TransferMatrix(A, B, C, D);
}

From source file:com.crunchify.jsp.servlet.ChartServlet.java

public JFreeChart getChart() {

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.addValue(25.0, "Series 1", "Category 1");
    dataset.addValue(34.0, "Series 1", "Category 2");
    dataset.addValue(19.0, "Series 2", "Category 1");
    dataset.addValue(29.0, "Series 2", "Category 2");
    dataset.addValue(41.0, "Series 3", "Category 1");
    dataset.addValue(33.0, "Series 3", "Category 2");

    JFreeChart chart = ChartFactory.createBarChart3D("3D Bar Chart Demo", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );/*from  www. ja va2 s .c o m*/

    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:ch.unil.genescore.vegas.DistributionMethods.java

public static double normalInversionUpperTailApprox(double p) {
    // approximates tail integral of normal distribution function:: only use for very low values; below 10^-14
    double lp = Math.log(p);
    double diff = 1;
    double a1 = 1;
    double a = 1;
    while (diff > 0.001) {

        a = Math.sqrt((-lp - Math.log(Math.sqrt(2 * Math.PI)) - Math.log(a1)) * 2);
        diff = Math.abs(a - a1);/*  www  .  j  a v a 2s  .  co  m*/
        a1 = a;

    }
    return (a);
}

From source file:org.spring.data.gemfire.cache.ClientCacheFunctionExecutionWithPdxTest.java

@Test
public void testFunctionArgumentTypes() {
    Class[] argumentTypes = functionExecution.captureArgumentTypes("test", 1, Math.PI,
            new TestDomainClass("DomainType"), TestEnum.TWO);

    assertNotNull(argumentTypes);//from w  ww  .j av a2 s.c  om
    assertEquals(5, argumentTypes.length);
    assertEquals(String.class, argumentTypes[0]);
    assertEquals(Integer.class, argumentTypes[1]);
    assertEquals(Double.class, argumentTypes[2]);
    //assertEquals(TestDomainClass.class, argumentTypes[3]);
    assertTrue(PdxInstance.class.isAssignableFrom(argumentTypes[3]));
    //assertEquals(TestEnum.class, argumentTypes[4]);
    assertEquals(PdxInstanceEnum.class, argumentTypes[4]);
}

From source file:ws.moor.bt.gui.charts.DownloadRatePerPeer.java

private JFreeChart createChart() {

    JFreeChart chart = ChartFactory.createBarChart("Top 20 Download Rates", "Remote IP", "KB/s",
            createDataset(), PlotOrientation.VERTICAL, false, false, false);
    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0));

    return chart;
}

From source file:net.sourceforge.processdash.ui.lib.chart.DiscLegendAxis.java

/**
 * Converts a coordinate in Java2D space on the legend axis to the corresponding
 *  disc area./*from w w w . jav a  2s  .c  om*/
 */
@Override
public double java2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge) {

    if (discItemDistributor == null) {
        // This should not happen since prior to using a legend axis, a DiscPlot
        //  should set a DiscItemDistributor.
        return 0.0;
    }

    double scaledDiameter = area.getMaxY() - java2DValue;
    double discDiameter = scaledDiameter / discItemDistributor.getScale();
    double discRadius = discDiameter / 2;
    double value = Math.PI * discRadius * discRadius;

    return value;
}

From source file:fsm.series.Series_SS.java

@Override
public double getFirstDerivativeIntegral(int m) {
    return Math.sin(Math.PI * m);
}

From source file:Estadistica.java

/**
 * Metodo calcular el valor gamma//from   w w  w .j a v a 2s .  c  om
 * param  una valor double
 * @return el valor gamma
 */
public static double gamma(double x) {
    double ans = 1;
    while (x > 1) {
        x = x - 1;
        ans = ans * x;
    }
    if (Math.abs(x - 1 / 2) < 1)
        return ans * Math.sqrt(Math.PI);
    else
        return ans;
}

From source file:net.sf.jdmf.util.MathCalculator.java

/**
 * Calculates the normal distribution for the attribute value of the
 * instance being classified. Uses all known values of this attribute
 * to calculate the mean and standard deviation. The probability density 
 * function used://from  w w  w. j av  a 2  s  . c o  m
 * <pre>
 *              1            ( -(x-m)^2 )
 * f(x) = ------------- * exp( -------- )
 *        sd*sqrt(2*PI)      ( 2*(sd)^2 )
 * </pre>
 * 
 * <code>m</code> - mean, <code>sd</code> - standard deviation
 * 
 * @param attributeValues all values of the attribute (for m and sd)
 * @param x the attribute value of the instance being classified
 * @return the normal distribution for x
 */
public Double calculateNormalDistribution(Comparable[] attributeValues, Double x) {
    Double mean = calculateMean(attributeValues);
    Double standardDeviation = calculateStandardDeviation(attributeValues, mean);

    Double normalDistribution = 1 / (Math.sqrt(2 * Math.PI) * standardDeviation);
    normalDistribution *= Math.exp(-Math.pow((x - mean) / standardDeviation, 2) / 2);

    log.debug("normalDistribution( " + x + " ) = " + normalDistribution);

    return normalDistribution;
}