Ok, this one goes beyond what i remember from geometry classes (appologies to Mrs. Gay, my high school geo. teacher)
I’m trying to evenly space a bunch of items (we’ll use dots for this example) around an ellipse. I can do it for a circle, but when transform it to an ellipse, it gets distored. I might be using the wrong equations to generate an ellipse, or maybe its more complicated. Here’s what i get, and notice how the points on the extremes of the x-axis are pushed closer together:

Update: Actually, it would be better to calculate a polygon of n sides that fits in the elipse. The sides must all be equal length, but the shape doesn’t need to be regular (all angles the same). That way, i’ll have n items on an ellipse, with equal space between each item (instead of equal distance on the circumference, which could make them closer together in linear space)
Sorry if you’re not a geek, but many of you are, and some of you even have prestigious geek friends who handle this sort of stuff in their sleep, whilst dreaming of mirrors curved in just such a way to calculate all sorts of intense math by reflecting light properly. Here’s my code:
// X radius
var XR:Number = 200;
// Y radius
var YR:Number = 50;
// number of points to plot
var n:Number = 45;
// an object to paint on
var mc:MovieClip = _root.createEmptyMovieClip("canvas", 1);
for (var r=0; r<2*Math.PI; r=r+(2*Math.PI/n)) {
// calculate x and y
var x = XR * Math.sin(r) + XR;
var y = YR * Math.cos(r) + YR;
// draw a 2x2 'point'
canvas.moveTo(x, y);
canvas.beginFill(0x000000, 100);
canvas.lineTo(x+2, y);
canvas.lineTo(x+2, y+2);
canvas.lineTo(x, y+2);
canvas.lineTo(x, y);
canvas.endFill();
}

May 31st, 2005 at 10:00 am
so what am i doing wrong? please advise if you can!
June 27th, 2005 at 12:54 pm
Hey bud… here’s my thought process
1. get the circumference of the ellipse
2. divide that by how many points you have.
3. walk around the ellipse placing points based on the distance calculated in step 2.
Just an uninformed guess at an answer.
June 27th, 2005 at 1:00 pm
yeah the problem is, “walk around the ellipse placing points based on the distance calculated in step 2″ is not simple.
try writing code to do it and you’ll understand.