displacement calculation