Working distance calculation