The distance function from the boundary of a domain with corners