Modified disp_vel_lin function to calculate vertical components