1 Reply Latest reply on Sep 14, 2007 2:04 PM by Some1Won

# Plotting points on a circle, like a radar.

Plotting points on a circle, like a radar.

I’ve been working with this one code for a while now that plots points in a circle where the center of the circle is today’s date and the out edge is 2 or 3 years out. The code places each point the correct distance from center randomly around the center point. It’s been working great, but now my boss wants to see the circle split into 4 quadrants. Now the points need to be within one of the quads dependant on two variables (area & port). I think the easiest way to explain it is that the circle is cut up like –

Top half = application
Bottom half = infrastructure
Left half = global wide
Right half = area wide

The math is really too far over my head at this point, so I’m hoping someone has the knowledge to help out with this.

If you put the code on the first frame and add a circle MC to the stage, call it myCircle, and have a point in your library with the id myPoint you can run this to see it work

Code:
• ###### 1. Re: Plotting points on a circle, like a radar.
I actually don’t have flash here so this is based on a quick skim of your code, but instead of “var angle = random(360);” (which I presume generates an random angle that you use to spreads your point around the middle of the center), you could generate a random angle from 1 to 89 instead.

Then when it comes to plot the points, you could add on an offset depending on what quadrant the point is supposed to appear in:

For the first quadrant it would be an offset of 0, so
1+ random( 89) + 0 would equal random angles from 1 to 89

Then for the next quadrant it would be an offset of 90:
1+ random( 89) + 90 would equal random angles from 91 to 179

The next quadrant it would be an offset of 180:
1+ random( 89) + 180 would equal random angles from 181 to 269

And finally, the last quadrant it would be an offset of 270:
1+ random( 89) + 270 would equal random angles from 271 to 359

I set the random angle going from 1 to 89, rather then 0 to 90, to avoid angles generated at 0,90,180, and 270 degrees... which would appear right on the border.