Improved code of computeVelocity to make it suitable for vectorization.