No I am trying to avoid division for you. The pi/4 is due to the fact the to get a tan I need sin/cos. This is implicit division. But you have two sine waves. So to get a cos wave you have to shift by pi/4. You would also have to shift by the actual phase diff in the case of the sine waves concerned.cannot assume a pi/4 shift and divide
An alternative math process is to consider them as exponentials. This reduces division to subtraction of exponents.
So you need your box to do the equivalent of taking the tan or calculating exp() and subtracting. This could be achieved with an old analogue computer, but I don't know how your box works.