Cube rotation math problem

hey guys, i've got a problem that's driving me mad. I'm designing a little simple physics sim in opengl that just uses cubes, and i'm trying to simulate realistic physics, but i first concluded that I'd have to account for the position of every vertex on the cube so i could test for impact against walls or other cubes. So, I made three 24 unit arrays, each the different axial component of a vertex. for example, if the first vertex was at position 1,1,1, the values of x[0], y[0], and z[0] would be 1 1 and 1.

Anyway,I had to write a function to move the cube, but that was no problem, i simply increase all the values in the x verticies array by the same amount and it moves positively in the x direction, etc. now i'm trying to come up with a function to rotate the cube that would work something like glRotate. I was planning to have my function take the following arguments:

1. magnitude of rotation (number of degrees) in float

2. three floats that would have a value between 0.0 and 1.0 for each axis to determine the magnitude of rotation in each. for example 90.0,1.0,0.5,0.0 would rotate the cube 90 degrees relative to the x axis, 45 degrees relative to the y axis, and none at all in relation to the z axis.

and anyway, the first attempts i've had at making this function have been total rubbish, they've failed miserably. My latest (and totally not working) code is as follows:
Code:

`void object::spin(float deg, float x, float y, float z) {`

float xlength,ylength,zlength,len1,len2;

deg = ((deg/180)*pi);

len1 = (sin(deg)*2);

len2 = (cos(deg)*2) - 2;

xlength = (len1 * z)+(len2 * y);

ylength = (len1 * x)+(len2 * z);

zlength = (len1 * y)+(len2 * x);

for (int n = 0; n<24;n++) { //xvertex, yvertex, and zvertex are the names for the arrays in which the vertex data is kept

xvertex[n] += xlength;

yvertex[n] += ylength;

zvertex[n] += zlength;

}

}

any help would be greatly appreciated. Thanks.