Partitioned Distance Function