Added Ramanujan's formula for an approximation of the circumference of an

ellipse. I didn't end up using it in the ArcPath, but it will surely come
in handy eventually.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1690 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-09-17 04:00:09 +00:00
parent 311846fced
commit 9ee8dde710
@@ -1,5 +1,5 @@
//
// $Id: MathUtil.java,v 1.4 2002/05/17 21:13:03 mdb Exp $
// $Id: MathUtil.java,v 1.5 2002/09/17 04:00:09 mdb Exp $
package com.threerings.media.util;
@@ -45,4 +45,15 @@ public class MathUtil
{
return lineToString(p1.x, p1.y, p2.x, p2.y);
}
/**
* Returns the approximate circumference of the ellipse defined by the
* specified minor and major axes. The formula used (due to Ramanujan,
* via a paper of his entitled "Modular Equations and Approximations
* to Pi"), is <code>Pi(3a + 3b - sqrt[(a+3b)(b+3a)])</code>.
*/
public static double ellipseCircum (double a, double b)
{
return Math.PI * (3*a + 3*b - Math.sqrt((a + 3*b) * (b + 3*a)));
}
}