Friday, March 10, 2006

Perimeter of an ellipse

Define an ellipse as

x^2/a^2 + y^2/b^2 = 1

then the perimeter P is calculated with

P = 4*a*E(e)

where E() is the complete elliptic integral of the second kind, and the eccentricity e is

e = sqrt(1 - b^2/a^2)

The complete elliptic integral of the second kind can be defined as an integral:

E(z) = integral( sqrt( 1 - z*(sin(x))^2), x, 0, pi/2 )

There are a variety of numerical methods to find E(z), but just using the v200 nInt() function for numerical integration works fairly well because the integrand is well-behaved with no discontinuties. Calculating E(z) with nInt() executes in about 2 seconds, with an RMS error of 1.8E-11 for 11 samples of z on [ -1, -0.8, ... , 0.8, 1 ].

For a lot of ellipse information and relationships see the Mathworld entry. You can calculate E(z) at the Wolfram formula page. A minor cottage industry seems to have sprung up for simple functions to estimate the ellipse perimeter, the most complete overview is here.

0 Comments:

Post a Comment

<< Home