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();
}
November 16th, 2005 at 4:12 am
Good piece of information, but don’t you think this might render differently if viewed in a browser with a different screen resolution, as the number of pixels is fixed. The page might not get screwed up but the left div may look too wide to look good.
Vikas
November 16th, 2005 at 1:40 pm
yeah, don’t look at my example for asthetic value, its just a how too.
thanks for the feedback!