Hello all. This is probably a simple problem for you guys, but my geometry is a bit rusty and I am hoping that you can help.


I am trying to arrange an arbitrary number of objects around the circumference of an ellipse. My first stab at the problem resulted in the use of a simple rotational matrix like this (note that I am using graphical Cartesian coordinates where y increases down from the top of the screen).



```
def rotate(x, y, theta)
  x_p = (x * Math.cos(theta)) - (y * Math.sin(theta))
  y_p = (y * Math.cos(theta)) + (x * Math.sin(theta))
  return [x_p, y_p]
end

```

That is obviously a circle, so I use the x coordinate and feed it into the equation of my ellipse to get the y(s). 


This works and does what it is supposed to, but the problem is that I am only incrementing theta to find my points, so obviously they are not equidistant around the circumference of the ellipse. That is what I am after, and any help would be greatly appreciated.


You can find a description of the problem with pictures in this thread:


<http://www.bigresource.com/Tracker/Track-flash-DO1WzX6KNq/>



Finding n points that are equidistant around the circumference of an ellipse
This answer assumes you are interested in finding $n$ points on an ellipse such that the arc lengths between successive points are equal.


As others mentioned, this problem involves an elliptic integral, which has no elementary expression. However, many scientific computation libraries are able to compute this function numerically, and you can take advantage of that. It looks like you're using Python; one possibility here would be the GNU Scientific Library (gsl) for which Python bindings are available.


Say your ellipse is parametrized by $x(t) = a \cos t$, $y(t) = b \sin t$ where $a$ is the semimajor and $b$ the semiminor axis. Let $e = \sqrt{1-b^2/a^2}$ be the eccentricity. The arclength from $(x(0), y(0)) = (a,0)$ counterclockwise to $(x(t), y(t))$ is given by $s(t)=a E(t,e)$, where $E(t,e) = \int\_0^t \sqrt{1-e^2 \sin^2\theta}d\theta$ is the "incomplete elliptic integral of the second kind". gsl implements this function as `gsl_sf_ellint_E`. The total arc length of your ellipse is $S = s(2\pi)$, which you can compute, so you need to find the value $t\_k$ such that $s(t\_k) = kS/n$, for each $k=0,\dots,n$. That is, you must solve for $t$ in the equation $s(t) = kS/n$.


But you are able to compute $s(t)$ numerically, and you also know the derivative $s'(t) = a \sqrt{1 - e^2 \sin^2 t}$ thanks to the fundamental theorem of calculus. Using this, it is a standard procedure to solve the equation iteratively using something like Newton's method. You could implement it yourself with a bit of reading, or use one of gsl's more sophisticated implementations, e.g. `gsl_root_fdfsolver_steffenson`.


