Reputation:
Let's say from the center of my screen I have an imaginary circle 100 pixels in radius and I want to generate an array of 360 pixel coordiantes that sit along that line. How can I do it? I just want to know from a central point, what the basic method is of generating the list, dont worry about specifics of screen centering or whatever. Lets just say the circle is at 500,500 on the screen.
The language I'm working with is a bit obscure so I'm just asking under the algorithm
tag to get a basic explanation of how to calculate the list.
I realize this should be easy, but my math skills suck. Im really not sure how to even start.
Upvotes: 3
Views: 591
Reputation: 80107
for i = 0.. 359:
Fi = i * Pi / 180
x = centerx + radius * Cos(Fi) //round to integer
y = centery + radius * Sin(Fi)
In case you want to generate all the points needed to draw a circle, consider some circle rasterization algorithm like Bresenham circle algorithm or midpoint one
Upvotes: 3