Sorry if this seems like a basic question, but I'm having troubles finding an answer in my research. I'm looking for a function that if given a test point (x, y, z) will return a real value describing whether the given point is
- On the surface of the shape $$f(x) = 0$$
- Inside the volume of the shape $$f(x) > 0$$
- Or outside the volume of the shape $$f(x) < 0$$
I've found such equations for a sphere and other shapes but cubic, and in general faceted shapes have eluded me. Unfortunately I'm a novice in this space with no formal training so any source or in depth explanations would be greatly appreciated.
Edit: As added bonus, is there an equation that handles rectangular cuboids?

Denote the center of the cube as $(a,b,c)$, and let its sidelength be $L$. Then the function $$ f(x,y,z) = \frac{L}{2} - \max(\lvert x-a \rvert, \lvert y - b \rvert, \lvert z - c \rvert) $$
has the properties you describe.
Essentially, this measures how far each coordinate is from the center of the cube along that coordinate axis. Outside the cube, each point has at least one coordinate of distance greater than $\frac{L}{2}$, points on the edges have at least one coordinate at distance $\frac{L}{2}$, and points on the interior have all coordinates within $\frac{L}{2}$ of the center.