At risk of missing the point, but...
Pretty much every programming problem boils down to these three questions:
- What information do I have?
- What information do I want to have?
- What operations will get me from 1 to 2?
[phasor~]
|
[cos~]
If we are starting here, then question 1 is "I have a phase, and a cosine."
Question 2 is "I want the phase."
Sooooooo... the Occam's Razor solution is not to discard the phase and recalculate it trigonometrically, but rather simply to use the phasor~ signal.
The mathematical problem that jameslo dealt with is that every value -1 < cosx < 1 occurs twice within a cycle. You can use the acos() angle directly if the cosx signal is falling (negative slope), but if it's rising, you must negate the angle.
But I think my practical point remains. If you need the phase, you can get the phase and the sinusoid using two objects, and have both signals available to do whatever you need. jameslo's solution involves 9 signal-rate objects. Eliminating the [phasor~] at the top ends up adding A LOT more complexity (more chances for bugs etc) and at a certain point (while acknowledging the appeal of intellectual curiosity), it stops being worth it.
The simplest solution that achieves the result is usually the best.
hjh