rotating a cube around origin

I'm working on a yahtzee program, and I want to make a neat animation of rolling dice. I've gotten as far as rendering the wireframe cube, and I've made some rotation functions for each axis that look something like this:

Code:

`th = atan(y / x);`

if ((x < 0 && y < 0) || (x < 0 && y > 0)) // -1/1 = 1/-1, correct for atan()

th += pi / 2;

th += pi / 20;

x = size * cos(th);

y = size * sin(th);

here's the part that stumps me, these functions work fine by themselves, but when I run them more than one at once I get weird (noncube) results. Does anybody have any ideas as to why this might be happening?