Added position calculation functions.