I'm looking for a characterization of functions $f:\mathbb{R}^n\to \mathbb{R}$ such that their zero level set $\{x\in \mathbb{R}^n:f(x) = 0\}$ is a union of hyperplanes. This is related to a search for functions $f(x)$ where $f(x)=0$ separates $\mathbb{R}^n$ into convex sets.
As an example, the function $f(x) = x_1 \sin(x_1+x_2)$ has this property and one can intuitively construct many other easy examples but I can't see what general properties they have in common.
This question seems to be related but is not quite what I was looking for.
Edit: I (somewhat intuitively) assume $f$ to be continuous but not necessariliy smooth, since that would not work with the option of piecewise definitions I also had in mind. However, if there is a nice characterization that depends on smoothness, I would definitely be interested in that too!
If $f$ is continuuous, then its zero set is closed.
Conversely, if $E\subset \mathbb R^n$ is closed, then there exists a continuous function $f$ whose zero set is precisely $E.$ Example: $f(x)=d(x,E).$ In fact, this $f$ is Lipschitz with Lipschitz constant $1.$
We can do better: If $E\subset \mathbb R^n$ is closed, then there exists $f\in C^\infty(\mathbb R^n)$ whose zero set is precisely $E.$
In these examples, it doesn't matter if the closed set $E$ is the union of hyperplanes or not.
I'm not sure there's much else to say, but perhaps you have a certain kind of property in mind.