# Torus equation in terms of tangent

So if I have an equation for a torus in $F(a,b) = (X, Y, Z)$ where $X = (R + r\cos a)\cos b$ and $0 < r < R$, how would I go about rewriting this equation for $X$ in terms of $\tan(a/2)$ and $\tan(b/2)$? I'm having a hard time doing the conversion. This might seem like an odd question but it's just the first step to a larger problem I'm working on but once I got this I'm good to go.

-
Are $x$, $y$ and $z$ functions of $a$ and $b$? Is $X$ the same as $x$? –  Fly by Night Feb 23 '13 at 18:46
Sorry I should have been more clear in my notation. x and X are the same. My question boils down to simply rewriting the equation X = (R+rcosa)cosb in terms of tan(a/2) and tan(b/2) instead of cosa and cosb or just in some form that incorporates those tangents –  user1855952 Feb 23 '13 at 18:48