I am working on some simulation software in which I have an entity (e) that is spiralling around a particular point (p). As e continues to move around p, the radius of the circle that it is following increases at a constant rate- causing it to follow the 'spiral' line rather than a 'circle' line.
I am currently working on displaying the number of times that e has completed a full circuit of p. A full circuit is defined by the point at which e passes through the angle that it was at from p when it first started moving.
At the moment, I the initial radius of the circle that e will follow is being set by the user, and I am then increasing that radius as e moves around p using the following calculation:
m_currentRadius = m_currentRadius + (m_Velocity*(elapsedSIMTime/3600.0));
where m_currentRadius is the current radius of the circle that e is following, m_Velocity is the speed at which e is moving, and elapsedSIMTime is the duration of time (in minutes) for which the simulaion has been running.
I am then incrememnting the 'number of circuits flown' by 1 every time the following condition is met:
if((current angle of e from p >= (original angle of e from p - 0.017)) && (current angle of e from p <= (original angle of e from p + 0.017)) && (the circuit number hasn't already been updated with this iteration of loop))`
The problem that I have with this condition, is that because it is being called several times every second (the number of times it will be called depends on the speed at which e is moving), as e continues to move around p, and its distance from p increases, this condition will be called more frequently (relative to the current angle of e from p).
Because of this, when the radius of the circle that e is currently following reaches a certain size, the condition that I am using to update the circuit number will be called/ performed more than once on the same circuit, and so will present an incorrect circuit number to the user.
I am aware that I will need to change the formula in the condition that I am using to check the angle of e from p, to account for the increase in the size of the radius of the circle... but I am unsure how to do this...
Basically, I need to change my formula to use a variable instead of the constant that I am currently using (0.017), and the value of this variable should decrease as the radius of the circle increases.
Effectively, I think I want to have a constant arc length, and calculate the range of angles that intersect this arc length depending on the size of the radius of the circle- because as the radius of the circle grows, the range of angles which intersect the defined arc will decrease.
If you take a constant arc length $a$, the angle (in radians) identified by this arc for a given radius $r$ is $\frac{a}{r}$. This angle tends to zero as $r$ increases.