Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dividing an ellipse into equal parts

328 views
Skip to first unread message

tallsteve

unread,
Mar 2, 2006, 5:25:29 PM3/2/06
to
Or to be more precise, dividing the circumference of an ellipse into
equal parts.

I'm trying to move items around an ellipse as part of an animation. If
I move round the ellipse in constant angular movements from the centre,
then the item moves faster when near to the centre of the ellipse and
slower round the ends.

(If my ellipse is 2w wide and 2h high, and the angle from the centre is
a, then I get the co-ordinates by x = w sin a and y = h cos a).

So, I want to move around the ellipse in constant steps around the
circumference. I know the width (2w) and height (2h) of the ellipse,
can calculate the foci (+f and -f), and have calculated the
circumference (c) successfully. Let z be the distance I want to move
round the circumference (so for say 30 steps, z = c / 30).

If I'm at a point (x, y) on the circumference, I want to find the point
(x1, y1) which is a distance z further round the ellipse.

The equation for the ellipse is ( x / w )^2 + ( y / h )^2 = 1.

Hence ( x1 / w )^2 + ( y1 / h )^2 = 1.

The new point will be at a distance z from (x, y), and so must lie on a
circle radius z from (x, y). So z^2 = ( x1 - x )^2 + ( y1 - y )^ 2.

This is where my 20 year old maths A level starts to struggle. I've got
two equations with two unknown values x1 and y1. (I know x, y, w, h,
and z). So all I should have to do is solve the simultaneous equations,
but that's where I get stuck. I end up with all sorts of horrors with
squares, cubes, powers of 4 etc.

The circle radius z will cross the ellipse in two places, so I'm
expecting to end up with a quadratic equation, which I can solve, but
need some help getting there..

(Assume that the width is greater than the height, and the foci lie on
the width axis which is horizontal. As I'm doing this for an animation
that works in pixels, i.e. whole integers, I don't need a massive
degree of accuracy to 17 decimal places...)

Hope my amateur explanations make sense.

Many thanks.

Julian V. Noble

unread,
Mar 2, 2006, 5:55:56 PM3/2/06
to

What do you mean by "equal parts"? I think you mean something like Kepler's
Law, where the radius vector from a focus to a point on the figure sweeps
out equal areas. Have a look at "Feynman's Lost Lecture" by David Goodstein.
Does Kepler's Law of equal areas in detail.

--
Julian V. Noble
Professor Emeritus of Physics

http://galileo.phys.virginia.edu/~jvn/

"As democracy is perfected, the office of president represents, more and
more closely, the inner soul of the people. On some great and glorious
day the plain folks of the land will reach their heart's desire at last
and the White House will be adorned by a downright moron."

--- H. L. Mencken (1880 - 1956)

Roy Stogner

unread,
Mar 2, 2006, 7:49:54 PM3/2/06
to
On Thu, 02 Mar 2006 14:25:29 -0800, tallsteve wrote:

> I'm trying to move items around an ellipse as part of an animation. If
> I move round the ellipse in constant angular movements from the centre,
> then the item moves faster when near to the centre of the ellipse and
> slower round the ends.
>
> (If my ellipse is 2w wide and 2h high, and the angle from the centre is
> a, then I get the co-ordinates by x = w sin a and y = h cos a).

If this is just for an animation, you'll probably be happy with an
approximate solution, which you can get with calculus.

You want sqrt(dx^2 + dy^2) to be a constant C. Taking derivatives,
dx = w cos a da
dy = -h sin a da
C^2 = dx^2 + dy^2 = (w^2 cos^2 a + h^2 sin^2 a) da^2

da = sqrt(C^2 / (w^2 cos^2 a + h^2 sin^2 a))

So plug in C, w, h, and a, and you'll get approximately the amount by
which you should increment a to move a distance C around the circumference.

If you're animating infrequently but need more accuracy, then separate
each animation step into multiple approximation steps - if the error you
get using 30 steps is too high, for example, you can get about 1% of that
error by taking 300 steps and only plotting every tenth.
---
Roy Stogner

tallsteve

unread,
Mar 3, 2006, 12:25:44 PM3/3/06
to
Thanks for your reply.

Either I don't understand your answer, or you've misunderstood my
explanation (not beyond the realms of possibility...). I don't need to
get involved in areas or anything too complicated.

For arguments sake, say the ellipse is 300 wide by 200 high. This gives
a circumference of 793.27. I want to move an item around the ellipse in
equal steps, so that it's speed is constant. So if my animation is 24
frames per second, and I want to take one second to get round, I need
to move the item round the circumference by 793 / 24 or roughly 33
units each time.

(Pixels only work in integers, although I will probably work in
floating point so that the items ends up exactly back at the start each
time.)

Martin Brown

unread,
Mar 3, 2006, 12:50:32 PM3/3/06
to
tallsteve wrote:

> Thanks for your reply.
>
> Either I don't understand your answer, or you've misunderstood my
> explanation (not beyond the realms of possibility...). I don't need to
> get involved in areas or anything too complicated.

So what you want to simulate is a point moving with constant speed along
an ellipse? Are you sure about that? It is non-physical behaviour.


>
> For arguments sake, say the ellipse is 300 wide by 200 high. This gives
> a circumference of 793.27. I want to move an item around the ellipse in
> equal steps, so that it's speed is constant. So if my animation is 24
> frames per second, and I want to take one second to get round, I need
> to move the item round the circumference by 793 / 24 or roughly 33
> units each time.

The thing to note here is that real objects moving under an inverse
square law move at a speed that depends on their distance from the
focus. Conservation of energy and momentum in real physics.


>
> (Pixels only work in integers, although I will probably work in
> floating point so that the items ends up exactly back at the start each
> time.)

You should be able to use a variant of Bresnam's algorithm to choose the
pixels on the ellipse. ISTR you have to do it one octant at a time.

Regards,
Martin Brown

tallsteve

unread,
Mar 3, 2006, 1:17:21 PM3/3/06
to
Ok, obviously haven't explained myself clearly. I just want to move an
object round a flat elliptical path on a computer screen at a constant
speed. Not simulate a planet, an orbit, a spinning wheel viewed from an
angle, etc. Actually, it's letters moving around an eliptical logo. So
no physical properties required. I've worked out how to keep the
letters perpendicular to a tangent to the ellipse at any particular
point, I just need to know how to move around a flat elliptical path at
a constant speed.

ISTR? Octant? Sorry, these mean nothing to me.

Peter Spellucci

unread,
Mar 3, 2006, 2:13:58 PM3/3/06
to

In article <1141409841....@v46g2000cwv.googlegroups.com>,

in order to get a simple solution you must: reparametrize the ellipse
such that the tangent vector has constant lenght one. then you simply
divide the parameterinterval into equal parts and plot.
hth
peter

David W. Cantrell

unread,
Mar 5, 2006, 12:53:47 PM3/5/06
to
"tallsteve" <goo...@sumogoldfish.com> wrote:
> Or to be more precise, dividing the circumference of an ellipse into
> equal parts.

OK, I'll help.

> I'm trying to move items around an ellipse as part of an animation. If
> I move round the ellipse in constant angular movements from the centre,
> then the item moves faster when near to the centre of the ellipse and
> slower round the ends.

True.

> (If my ellipse is 2w wide and 2h high, and the angle from the centre is
> a, then I get the co-ordinates by x = w sin a and y = h cos a).

The parameter a above does _not_ represent "the angle from the centre".
Don't feel bad. That's a common misconception. (But I'm surprised that none
of the other respondents mentioned the error.)

> So, I want to move around the ellipse in constant steps around the
> circumference. I know the width (2w) and height (2h) of the ellipse,
> can calculate the foci (+f and -f), and have calculated the
> circumference (c) successfully.

Did you do that using the complete elliptic integral of the second kind?

And later "tallsteve" <goo...@sumogoldfish.com> wrote:
> For arguments sake, say the ellipse is 300 wide by 200 high. This gives
> a circumference of 793.27. I want to move an item around the ellipse in
> equal steps, so that it's speed is constant. So if my animation is 24
> frames per second, and I want to take one second to get round, I need
> to move the item round the circumference by 793 / 24 or roughly 33
> units each time.

Correct.

IMO, what you need to be able to do is invert the incomplete elliptic
integral of the second kind, inverting with respect to its amplitude z (not
its parameter m). N.B. Since there are differing conventions, to avoid
confusion, let's agree here to use the convention used at
<http://functions.wolfram.com/EllipticIntegrals/EllipticE2/>.

Your computer system might have an implementation of that inverse; if so,
everything would be simple. But it's unlikely that it has such an
implementation. Since you just need a fairly crude approximation, using
just a few terms of a series for that inverse should be satisfactory. I'll
work out an example for you below. But first, you might want to look at two
previous threads:

"Inverting elliptic integrals" sci.math.research
<http://groups.google.com/group/sci.math.research/browse_frm/thread/6eb1aa7e07b1c382>

"n equally spaced points around the ellipse's perimeter" sci.math
<http://groups.google.com/group/sci.math/browse_frm/thread/10a64db323853322>


Now for the example, using the data you gave above. You already know that
your ellipse can be parametrized as x = 150 sin(t), y = 100 cos(t) and that
its perimeter is 793.27. You want 24 points on the ellipse so that the
lengths of the elliptic arcs between consecutive pairs of points are
approximately the same.

It's very convenient that you chose 24; it's divisible by 4. Let me suggest
that you _always_ use a number divisible by 4. Doing so simplifies things.
So in your example, we just need to divide the part of the ellipse in the
first quadrant into six arcs of approximately equal length.

I shall also assume, for greatest convenience, that we start with t = 0,
that is, that we begin at an end of the minor axis.

Here is part of a Mathematica notebook. I hope it's more-or-less
self-explanatory; if not, don't hesitate to ask questions.

In[1]= a = 150; b = 100; param = 1 - (b/a)^2;
quarterperimeter = a*EllipticE[param]

Out[1]:= 150*EllipticE[5/9]

In[2]= distance = %/6

Out[2]:= 25*EllipticE[5/9]

In[3]= N[%]

Out[3]:= 33.0529991443554

thereby confirming your "roughly 33 units".


In[4]= Normal[InverseSeries[Series[EllipticE[z, m], {z, 0, 14}], d]]

Out[4]:= d + (d^3*m)/6 + (1/120)*d^5*(-4*m + 13*m^2) +
(d^7*(16*m - 284*m^2 + 493*m^3))/5040 +
(d^9*(-64*m + 4944*m^2 - 31224*m^3 + 37369*m^4))/362880 +
(d^11*(256*m - 81088*m^2 + 1406832*m^3 - 5165224*m^4 + 4732249*m^5))/
39916800 + (d^13*(-1024*m + 1306880*m^2 - 56084992*m^3 + 474297712*m^4 -
1212651548*m^5 + 901188997*m^6))/6227020800

The result above gives an approximation of the needed inverse.

In[5]= InvE[d_, m_] := d + (d^3*m)/6 + (1/120)*d^5*(-4*m + 13*m^2) +
(d^7*(16*m - 284*m^2 + 493*m^3))/5040 +
(d^9*(-64*m + 4944*m^2 - 31224*m^3 + 37369*m^4))/362880 +
(d^11*(256*m - 81088*m^2 + 1406832*m^3 - 5165224*m^4 + 4732249*m^5))/
39916800 + (1/6227020800)*(d^13*(-1024*m + 1306880*m^2 - 56084992*m^3 +
474297712*m^4 - 1212651548*m^5 + 901188997*m^6));

In[6]= N[Table[{a*Sin[t], b*Cos[t]} /. t -> InvE[d, param],
{d, 0, quarterperimeter/a, quarterperimeter/(6*a)}]]

Out[6]:= {{0., 100.},
{32.93229464625545, 97.56015573157862},
{65.09394815658442, 90.09323050999978},
{95.44895809488033, 77.14199432389246},
{122.25147255789417, 57.94471486752196},
{142.21788527772756, 31.79149506904233},
{149.99996319648417, 0.07005094462200027}}

So we got a list of 7 points. You wouldn't really want to use the last one;
instead, you'd use exactly (150, 0). I showed the last point simply so that
you'd see how far off the approximation was there. Of course, to get the
rest of the 24 points, in the other quadrants, just use symmetry.

David W. Cantrell

tallsteve

unread,
Mar 6, 2006, 7:25:33 AM3/6/06
to
David, thanks for your answer.

> Did you do that using the complete elliptic integral of the second kind?

Sadly, I don't know what that means, but I can tell you how I got my
results:

foci f = sqrt(a^2 - b^2)

circumference

= PI*SQRT(2*(a^2+b^2)-((a-b)^2)/2) gave 793.213263
= PI*(3*(a+b)-SQRT((a+3*b)*(b+3*a))) gave 793.2718788 (Ramanujan 1)
= PI*(a+b)*(1+3*h/(10+SQRT(4-3*h))) where h = (a-b)^2/(a+b)^2 gave
793.2719795 (Ramanujan 2)
= PI*(a+b)*(3*(1+h/4)+1/(1-h/4)))/4 (h as above) gave 793.2719783
(Hudson)

Any of these would be more than accurate enough for my purposes.

"roughly 33 units" - sorry for my horrible non-mathematical english.

> invert the incomplete elliptic integral of the second kind,

Alas, you could be speaking Greek from here on. I feel myself getting
out of my depth...

> Your computer system might have an implementation of that inverse;

I'm using Actionscript under Macromedia Flash (Java derivative). It's
primarily a graphical language, not a mathematical one. It can draw an
ellipse, but not much more...

> It's very convenient that you chose 24; it's divisible by 4. Let me suggest
> that you _always_ use a number divisible by 4. Doing so simplifies things.
> So in your example, we just need to divide the part of the ellipse in the
> first quadrant into six arcs of approximately equal length.

That makes sense.

> Here is part of a Mathematica notebook. I hope it's more-or-less
self-explanatory;

I'm not familiar with this system. How is an ellipse represented by z
and m? I'm sorry if the answer is in the link to wolfram you provided,
but I'm rapidly realising that I'm a programmer and not a
mathematician.

However, the first part appears to be confirming my calulation of part
of the cirumference, so if you're in agreement, I don't need to concern
myself with how it works.

I can follow the formula in the second part, which follows on from one
of the threads you linked to. I will do some experiments in Excel to
see just how few of these fractions I need to be accurate enough for my
purposes.

> So we got a list of 7 points.

At this point, you've no idea how tempting it is to simply hard code
these (and their various reflections) into an array in the program.
Would run a lot quicker too!

On a serious note, knowing what the correct results are will help me
test any code that I develop.

Thanks for your help.

Steve

tallsteve

unread,
Mar 6, 2006, 7:40:23 AM3/6/06
to
Roy

Thanks for your reply, which was written in language I could
understand! Sorry for the delay in replying.

Have run your formula through Excel and the results match those of
David W. Cantrell above. I do get some rounding errors, but hey, I'm
working in whole pixels anyway...

I think what I'll do is use the formula to calculate an array of points
on entry to the program, then use the array for processing efficiency.
So I'll still be able to change the number of steps easily. And I can
tweak the array to make sure everything ends up back where it started!

Thanks again
Steve

0 new messages