The magic words are $\tan(\theta/2).$ That substitution reduces your question to asking which rational functions $\mathbb{R} \rightarrow \mathbb{R}$ are homeomorphisms. Those are precisely the functions whose derivative does not change sign, so differentiating our function we get a rational function which does not change sign. This is true if and only if both the numerator and denominator do not change sign, so let's just say they stay positive (or non-negative if you want homeo instead of diffeo). A polynomial is nonnegative on the real line if and only if it is the sum of (two) squares.
So, there you have it.