Java String Ellipse ellipseCircumference(double a, double b)

Here you can find the source of ellipseCircumference(double a, double b)

Description

Estimate the circumference of an ellipse.

License

Open Source License

Parameter

Parameter Description
a a parameter
b a parameter

Declaration

public static double ellipseCircumference(double a, double b) 

Method Source Code

//package com.java2s;
/*//from  w  ww .ja va 2s . c  o m
  MathUtils.java
    
  (c) 2012 Edward Swartz
    
  All rights reserved. This program and the accompanying materials
  are made available under the terms of the Eclipse Public License v1.0
  which accompanies this distribution, and is available at
  http://www.eclipse.org/legal/epl-v10.html
 */

public class Main {
    /**
     * Estimate the circumference of an ellipse.
     * 
     * @from http://en.wikipedia.org/wiki/Ellipse#Circumference
     * @param a
     * @param b
     * @return
     */
    public static double ellipseCircumference(double a, double b) {
        if (a + b == 0)
            return 0;
        double aDb = a - b;
        double aPb = a + b;
        double diffSumQuotSq3 = 3 * (aDb / aPb) * (aDb / aPb);
        double dividend1 = diffSumQuotSq3;
        double divisor1 = 10 + Math.sqrt(4 - diffSumQuotSq3);
        return Math.PI * (a + b) * (1 + dividend1 / divisor1);
    }
}

Related

  1. ellipseCircum(double a, double b)
  2. ellipseString(StringBuilder builder, int maxLength)
  3. ellipsify(String message)
  4. ellipsis(final String text, final int length)
  5. ellipsis(final String text, int length)