Formula to calculate ellipse Perimeter - Android java.lang

Android examples for java.lang:Math Formula

Description

Formula to calculate ellipse Perimeter

Demo Code


import java.text.DecimalFormat;

public class Main{
    private static final double PI = 3.141592653589793;
    private static double result;
    public static double ellipsePerimeter(double radius1, double radius2)
            throws InvalidInputException {
        if (radius1 >= 0 && radius2 >= 0) {
            result = (2 * PI * Math.sqrt(0.5 * radius1 * radius1 * radius2
                    * radius2));//ww  w .j av  a 2  s . co m
            return result;
        } else {
            throw new InvalidInputException();
        }
    }
}

Related Tutorials