I'm trying to come up with an equation which, given an index within an arbitary number of elements (the most natural example would be 12, as in 12 numbers on a clock), along with an arbitrary radius, provides the point at which that element should be placed.
For example, if we are to use the example of a clock, and consider the center of the circle as the point [0, 0], and using a radius of, say, 100, then the '12' would be located at [0, -100], the '3' located at [100, 0], the '6' at [0, -100], and so on.
Does anyone know of an equation I could use to find the point for an arbitrary index using an arbitrary number of elements?
Thanks!
and welcome to the site.
Suppose you have $n$ elements, and you want to look at the co-ordinates of the $i$th element, and you have a radius of $r$. Then the co-ordinates are simply:
$(r\cdot\cos(2\pi\cdot\frac{i}{n}),r\cdot\sin(2\pi\cdot\frac{i}{n}))$
Or if you're more used to using degrees than radians:
$(r\cdot\cos(360^\circ\cdot\frac{i}{n}),r\cdot\sin(360^\circ\cdot\frac{i}{n}))$
This assumes that your circle is centered at $(0,0)$. If your circle is centered instead at $(a,b)$, then you simply add $a$ and $b$ to your co-ordinates:
$(a + r\cdot\cos(2\pi\cdot\frac{i}{n}),b + r\cdot\sin(2\pi\cdot\frac{i}{n}))$
In these cases, per common mathematical convention, the numbering starts along the $x$-axis with $i=1$, and goes around evenly until $i=n-1$. If $i=n$ it simply starts again. If you need to change the direction or starting point, that is also possible.
For example, if you wanted to start at $90^\circ$, simply add $90^\circ$ inside the trig function (or $\pi/2$ if you're working with radians):
$(a+r\cdot\cos(360^\circ\cdot\frac{i}{n}+90^\circ),r\cdot\sin(360^\circ\cdot\frac{i}{n}+90^\circ))$