I have an object with vec2 position, velocity, and destination with 2 variables maxspeed and acceleration. In each step, its position is calculated as follows:
vec2 desiredVel = destination - position;
var dist = desiredVel.length;
if (2 * dist * acceleration < currentSpeed*currentSpeed)
desiredVel.zero();
vec2 steering = desiredVel - velocity;
steering.setLength(acceleration);
velocity += steering * dt;
velocity.truncate(maxspeed);
currentSpeed = velocity.length();
position += velocity * dt;
Basically the object will accelerate to its maxspeed towards destination, then maintains speed until the a certain distance to destination. At that distance, the object will decelerate at the -max acceleration rate so that it stops approximately to the destination point.
My question is that if I have an object with an initial velocity and I set a destination point, how can I estimate the time it will take to reach the destination point? Assuming its maxspeed and max acceleration doesn't change and no other force/acceleration applies to the object in the path.