Let $\{U\_i\}\_{i=1}^{I}$ be a non-empty and finite collection of non-empty, disjoint, open, (and obviously bounded) subsets of $[0,1]^n$. Suppose also that $[0,1]^n=\cup\_{i =1 }^{ I} \overline{U\_i}$. Under what condition does there exist a continuous function $f:[0,1]^n\rightarrow [0,1]^I$ such that
$$
x\in U\_i \Leftrightarrow \|f(x)-e\_i\|< \min\_{\tilde{i}\neq i}\|f(x)-e\_{\tilde{i}}\|
;
$$
where $\{e\_i\}\_{i=1}^I$ is the standard basis of $\mathbb{R}^I$.




---


**What I have tried:**


* In the case where each $U\_i$ is convex: If $U\_i$ is convex then there it is star-shaped so there is an $x\_i\in U\_i$ for which every $x \in U\_i$ can be reached by a line segment emanating from $x\_i$ and contained within $U\_i$. Note, since $U\_i$ is convex then such a line segment must stay within $U\_i$. Thus, for any $x'\in \cup\_{i\in I} (0,1)^N$,
$
\|x-x\_i\|<\min\_{\tilde{i}\neq i} \|x-x\_{\tilde{i}}\|.
$ So we set:
$$
f(x)= \left(\|x-x\_i\|
e\_i
\right)\_{i=1}^I.
$$
Is this reasoning correct?
* For the general case, I was trying to use Urysohn's Lemma but alas, to no avail..



Condition for existence of a continuous function realizing a partition
For $x \in U\_i$ let $f(x) = r e\_i$ where $r = \min\_{y \notin U\_i} |x - y|$, i.e. the radius of the largest open ball centered on $x$ and contained in $U\_i$. If $x$ is not in any $U\_i$ let $f(x) = 0$. Note that $|f(x) - f(y)| \leq |x - y|$


