I am trying to layout a circle, given the arc length l, radius r and center (cx, cy). I need to find all the n points that are on the circle.
What I've tried so far:
The first part is to find n:
n = floor(2*pi*r/l); i.e. dividing circumference in to equal number of arcs.
pi is in radians
Now my next task is to find the n points. I would assume my first point to be p(cx+r, cy) and try to go on clockwise direction from there.
for(each point)
{
draw(p);
angle = atan2(py-cy, px-cx);
angle = angle - (RadiansToDegrees(l)/r);
px = cx + r * cosine(angle);
py = cy + r * sine(angle);
}
This doesn't seem to work, I am not sure where I am making a mistake. Please help.
If you want to divide a circle into $n$ arcs you can split the angle $2 \pi$ into $n$ parts: $\left[0, 2\pi \cdot\frac{1}{n}\right]$, $\left[2\pi \cdot\frac{1}{n},2\pi \cdot\frac{2}{n}\right]$,...,$\left[2\pi \cdot \frac{n-1}{n},2\pi\right]$. Use the endpoints of these intervals to define points on your circle: $p_k =\left(c_x+r\cos(2\pi\cdot\frac{k}{n}),c_y+r\sin(2\pi\cdot\frac{k}{n})\right); k=1,2,3,...,n$. When $k=0$ you get the point you wanted to start with, and you can check that the points are being plotted counter-clockwise as $k$ increases.