Interaction between ellipses and balls.

After solving the problem of calculating the intersections between arbitary ellipses I became interested in having 'balls' realistically rebound off the ellipse perimeter.

In this sketch there are four overlapping ellipses each with its own set of balls.

As you can see each set of balls are constrained to their own ellipse but bounce off each other and off the ellipse perimeter.

In this sketch all the balls are constrained to the blue ellipse but are excluded from the green ellipses.

It uses the same code for internal and external rebounds.