title: Simulating an object under constant acceleration with a maximum speed
body: <p>I am trying to simulate an object in 2 dimensions with a set maximum speed, and I'm having difficulty constructing a mathematical model of the objects behaviour when it is at maximum speed but it is both not moving in the correct direction <em>and</em> further acceleration is partially blocked by the maximum speed limit.</p>
  
  <p>E.g. it's maximum speed is √2, it's currently heading at (1,1) and it should really be heading at (√2, 0). If it just accelerates directly along the x-axis, it would break the speed limit it is working under.</p>
  
  <p>Instead it needs to 'slide' it's velocity round to the correct direction over the course of time. What I have been doing is doing is calculating the new speed and scaling it by the maximum if it gets too high:</p>
  
  <pre><code>newVelocity = oldVelocity + acceleration * dt;
  if(newVelocity.getLength() &gt; maxSpeed){
      newVelocity = newVelocity.scale(maxSpeed);
  }
  </code></pre>
  
  <p>Which does work (sort of), but I'm needing to refactor it to be smoother - as in, not dependent on the granularity of the simulation - at the moment, I get different results if I do one pass as opposed to (say) two passes with half the value of dt.</p>
  
  <p>What I have been trying to do is model it as the speed being a point on the circle, and then calculating the amount of the acceleration applied as the tangent of the circle</p>
  
  <p><a href="https://i.stack.imgur.com/xP73w.png" rel="nofollow noreferrer">Diagram of what I mean</a></p>
  
  <p>But (and this is where my mechanics and calculus fails me) is how to turn this calculation of the momentary angular velocity derived from the current velocity angle and the acceleration applied into a time based formula which I can use to work out the change in actual velocity over a single simulation tick.</p>
  
  <p>I'm almost certain that this problem has a fairly straightforward solution - I'm just unable to work out what set of terms to google for.</p>