Advanced: Equations of Motion

v' = if |v proj a| < L - |t*a|: v + t*a if L - |t*a| <= |v proj a| < L: v + (L - |v|cos(θ))*a/|a| if L <= |v proj a|: v

|v'| = if v proj a < L - |t*a|: sqrt(|v|^2 + |t*a|^2 + 2|v||t*a|cos(θ)) if L - |t*a| <= v proj t*a < L: sqrt(|v|^2 sin^2(θ) + L^2) if L <= v proj t*a: |v|

cos(φ) = v*v'/(|v||v'|) cos(φ) = if v proj a < L - |t*a|: (|v| + |t*a|cos(θ))/sqrt(|v|^2 + |t*a|^2 + 2|v||t*a|cos(θ)) if L - |t*a| <= v proj t*a < L: (|v| + L*cos(θ) - |v|cos^2(θ))/sqrt(|v|^2 sin^2(θ) + L^2) if L <= v proj t*a: 0

L - |t*a| >= |v|*cos(θ) (L - |t*a|)/|v| >= cos(θ) = -|t*a|/|v| L - |t*a| >= -|t*a| L >= 0

(L - |t*a|)/|v| >= cos(θ) = -|t*a|/(2*|v|) L - |t*a| >= -|t*a|/2 2*L >= |t*a|

For a deeper analysis of air strafing physics, we are mainly interested in two functions: The change in magnitude of velocity (change in speed) at each frame, and the change in direction at each frame. For the first, recall the equation above for v':By applying the law of cosines to this, we can find the magnitude of v':Then the change in speed is simply |v'| - |v|. Let's first take a look at how change in speed varies with angle. In this and later graphs, we will look at two typical examples, a scout at 400 HU/s (max ground speed), and a soldier at 700 HU/s (a fast speed after a rocket jump).Not surprisingly, the scout, with lower speed and higher acceleration, gains speed faster. We can also clearly see the three sections here: No acceleration at low angles, a smooth hump in the middle when acceleration is limited by the the speed limit, and an approximately straight line at large angles when the speed limit no longer applies.The later first transition for the soldier is caused by his higher speed. This transition happens when L = v*cos(θ), so higher speeds require a larger angle to start accelerating. The second transition is moved forwards, both by the higher speed and the by lower acceleration. This transition happens when L - |t*a| = v*cos(θ), so higher speeds and lower acceleration cause smaller transition angles.Most importantly, notice that the maximum increase in speed is achieved at an exactly 90 degree angle. This is true regardless of speed or class, and can easily be verified with the equation above. Let's now take a look at how change in speed depends on speed, assuming a perfect 90 degree angle is maintained.We can clearly see that change in speed decreases with speed. At this angle the change in speed is simply sqrt(|v|^2| + L^2) - |v|. Since this doesn't depend on acceleration, class does not matter.The change in direction is simply the angle between v' and v, which we will call φ. We can find this by applying the above equation to the angle definition of the dot product, v*v' = |v||v'|cos(φ).Let's first take a look at φas a function of θ:The three sections are again clearly visible. At low angles, we don't turn at all. At larger angles, turning increases approximately linearly, but is limited by the speed limit. At larger angles still, the turn is approximately constant (though not quite).We can find the maximum possible turn with calculus, or by noting that in the non-limited case (v proj t*a <= L - |t*a|), the maximum turn occurs when v' is perpendicular to a. Then θ = cos(-|t*a|/|v|) and φ= asin(|t*a|/|v|). This is shown here . We can substitute this back in to the limit equation to verify that this is allowed, and we get,Which is of course true, so we don't need to worry about the other cases. Therefore the maximum possible turning rate is asin(|t*a|/|v|)/t degrees per second, and it is achieved at θ = acos(-|t*a|/|v|).There is a catch with this though: To turn at this rate, we must lose some speed. You can see this in the figure above, or by plugging θ = acos(-|t*a|/|v|) into the speed change equation. So the next logical question to ask is, how fast can we turn without losing speed? To solve this we simply check the equation for change of speed, and assuming the non-limited case, we solve sqrt(|v|^2 + |t*a|^2 + 2|v||t*a|cos(θ)) = |v|, which gives us θ = acos(-|t*a|/(2*|v|)), and then φ= 2*sin(|t*a|/(2*|v|)). (We could also have found this geometrically, as shown here ). Checking the limit equation:If we check this for all classes, we find this is true for every class except scouts (we can see this in the graph of change in speed versus angle for scouts, above). For the scout we therefore need to take the limited case from the speed change equation. We solve sqrt(|v|^2 sin^2(θ) + L^2) = |v| and get θ = acos(L/|v|) and φ= 2*sin(L/|v|). (This can also be found geometrically, in the same way as above)But even if we know what θ we want to maintain, how can we hold this angle while turning? For most angles, this is surprisingly simple: We just turn our mouse at the turning speed. If our θ is too small, our velocity won't turn as much as we want, which will increase θ. If our θ is too large, our velocity will turn faster than we want, which will decrease θ. Therefore if we want to turn at 360 degrees per second, we just move our mouse at 360 degrees per second.The exception is if we want to maintain the maximum possible turning. In this case, if our θ is too large, our velocity will turnthan we want. This will increase θ, and therefore increase our error. As θ increases, we will lose speed. This will continue until our speed is low enough that the velocity can turn fast enough to catch up. So unless you want to lose speed, give yourself some room for error when turning.