start calculate the direction