I have the product of some Heaviside functions or sign functions, a simple example could be:
HeavisideTheta[q^2 - 4]*Sign[q - 3]
Another slightly more complicated example, involving a quartic function could be:
HeavisideTheta[Sqrt[((q - 3)^2 - 10)^2 + 15] - 8]
Clearly the resulting function will be composed of many steps, so I would like to convert it to a piecewise function. For the example before, the result would be:
Piecewise[{{-1, q <= -2}, {0, -2 < q <= 2}, {-1, 2 <= q < 3}}, 1]
Except for (maybe) a zero measure set, for which I don't care. Many times the variable appears quadratically or quartically inside the functions, so solving to find the zero may be non trivial, but it can always be done exactly by Solve[] or Reduce[].
I need to repeat this procedure a lot of times, so I would like to automate the procedure... Is there a way to teach Mathematica how to do it?