calculate velocities