tags:

views:

80

answers:

2

Given a point P on a 'canonical' ellipse defined by axes a, b, and an arc length s, how can I find a point Q, also on the ellipse, that is s clockwise along the elliptical curve from P — such that if I were to start at P and 'walk along' the elliptical curve for a distance of s, I would reach Q — programatically and without breaking the computational bank?

I have heard that this can be computed through some sort of elliptical integration, but I need to do this a bunch, and quickly. What I'm looking for is an easy to use, computationally inexpensive, and fairly accurate approximation method. Or at least a method that is one or two of those things. I will be implementing this in python.

Edit: alternatively, I might be forced to create a lookup table of position values around ellipses (I might only need in the 10s of dissimilar ellipses). How should I do this, and what method can I use to fill it?

+2  A: 

You'll need to integrate the ellipse equation. It's not difficult, actually.

Take a look at the equations here:

http://mathforum.org/library/drmath/view/51945.html

Since you're using python, the Runge-Kutta for integration is implemented in Python here (I don't know the license, though):

http://doswa.com/blog/2009/04/21/improved-rk4-implementation/

Just on step 3 and 4 of mathforum solution you already have a value for ds (the arc lenght) and you want dx.

After finding dx, use step 6 to find y.

Vitor Py
Agreed; true mathematical integration is as computationally simple and accurate as you're ever going to get. I think what the asker is trying to avoid is "integration" in the sense of [Euler Integration](http://en.wikipedia.org/wiki/Euler_method) or [Verlet Integration](http://en.wikipedia.org/wiki/Verlet_integration), which involves *literally* adding tiny `ds`'s to a point until you total up to your desired `s`.
Justin L.
+1  A: 

You could use scipy.special.ellipeinc to calculate the arclengths. (More details are given by Roger Stafford here.)

If that isn't fast enough, you could wrap the arclength calculation in a function and use a memoize decorator to cache the result of previous (arclength) function calls.

Or, as you've mentioned, you could pre-calculate the values you need, and store them in a dict.

unutbu