For rotation around the z-axis:
x' = x cos za - y sin za;
y' = x sin za + y cos za;
For rotation around the x-axis:
y' = y cos xa - z sin xa;
z' = y sin xa + cos xa;
For rotation around the y-axis:
x' = x cos ya + z sin ya;
z' = - x sin ya + z cos ya;
Of course, x', y' and z' are the new coordinates. I'll let you figure out how to plug this into your code. It's not hard, but not as simple as you hoped.