I have a question. I have an algorithm that computes the trajectory of a body moving in a circle. The program repeats the following at short intervals to update the body's X and Z positions:
$$x = \mathrm{X_c} + R\cos\left(\frac{2\pi}{T}t\right)$$
$$z = \mathrm{Z_c} + R\sin\left(\frac{2\pi}{T}t\right)$$
$X_c$ and $Z_c$ are the x and z positions of the rotation axis, respectively. The $t$ value is increased by $1$ with each update. In turn, $T$ means the time it takes the body to complete one circle. The problem is that changing the radius $R$ value changes the speed of the body. I want a constant speed, independent of the radius. How can I get rid of the $T$? Ideally, the speed should be predefined. This means that regardless of the radius of the circle, the body should always move at a fixed speed. Is there a way? I will be grateful for your help.
For an object undergoing circular motion (wlog - around the origin) with uniform angular frequency $\omega$ and radius $R$, a 'time' dependent parameterization via $t$ would be:
$$ (x,y) = (R\cos(\omega t), R\sin(\omega t))$$
The angular speed is $v=\omega R$ which can be verified by taking the derivative w.r.t $t$. So if you want to preserve $v$ while changing $R$ you need to compensate for that change by an inverse change in $\omega$.
Example: Suppose we begin from initial angular frequency $\omega_1$ and initial radius $R_1$. We now change the radius to $R_2$ but want to keep the previous angular speed $v_1=\omega_1 R_1$. If you set the new angular frequency in the following way: $\omega_2 = \omega_1\frac{R_1}{R_2}$ then you can see that it will compensate for the change in the radius appropriately:
$$ v_2 = \omega_2 R_2 = \omega_1\frac{R_1}{R_2}R_2=\omega_1R_1 = v_1$$
So the angular speed did not change, as required.
Note also that since the above gives $\omega_1 = \frac{v_1}{R_1}$ and $\omega_2 = \frac{v_2}{R_2}$ we can read off a general expression for a "$v$ preserving" $\omega$ as a function of a variable radius $R$ that you may want to use:
$$ \omega(R) = \frac{v}{R}$$
In your case the angular frequency is currently fixed at $\omega = \frac{2\pi}{T}$ which means that a complete revolution always takes $T$ time units. But since you care about the speed $\omega R$ being constant, you can't keep the $T$ fixed as well. So you will have to adjust your code in some way to use an $\omega$ that is variable rather than fixed in order to achieve that. You may still initialize it to the same value $\frac{2\pi}{T}$ but it will have to change when the radius changes, as explained earlier.