A vehicle currently at a point U = (ux, uy) is moving counter-clockwise along a circle of radius R with speed s and direction d (i.e. tangent to the circle makes an angle d with the X-axis.) What position V = (vx, vy) will it be at in time t? The center of the circle is not specified. The way I see it, after time t it will travel st or an angle of st/R along the circle. But I am lost trying to compute V from this info. I can first find the center C of the circle based on (ux, uy), R and d. And then find where vector CV points, and hence V. But that's a whole lot of cosines and sines. I am constrained by CPU, so maybe one sine/cos/tan is acceptable or one or two squares/square roots are acceptable.
1 Answers
This calls for a diagram, but alas I lack the skill.
I assume that the radius speed and time interval are such that the vehicle will not travel more than halfway round the circle in the time available.
Let V be the point the vehicle will be at t seconds after it is at U. Let the centre of the circle (whose coordinates will not be needed) be O. Then the length of the arc from U to V is
A = s*t
and so the angle subtended at O is
a = A/R radians.
The direction from U to V will be the same as the direction of the tangent to the circle at a point midway between U and V, ie
e = d + a/2
The distance from U to V is the length of the chord from U to V. The midpoint of the chord is the vertex of two congruent right angled triangles whose hypoteneuses have length R, and the angle at O is a/2. Therefor the length of the chord is
C = 2*R*sin( a/2)
Finally
V = U + C*(cos(e), sin(e))
You may also want the direction of the tangent at V. This is d+a.
Note that if you store the direction d as a unit vector rather than an angle you can save some sin & cos calls as the direction of the chord is then the direction d rotated through a/2, and the direction at V is d rotated through a.
sin(x) = x
andcos(x) = 1 - 0.5x^2
are reasonable approximations. Is that good enough? – harold