Calculating the motion parameters