I'm calculating matrices by hand. Translations are fine:
void Translate (float x, float y, float z, float[4][4] m) {
Identity (m);
m[3][0] = x;
m[3][1] = y;
m[3][2] = z;
}
If I multiply a vector with this matrix, I get the correct transformation. My problem now is Rotations. I copied the definition from the OpenGL reference on glRotation, but I can't get it right. Can you spot my mistake?
void Rotate (float angle, float x, float y, float z, float[4][4] m) {
float c = cos (angle);
float s = sin (angle);
m[0][0] = x*x*(1-c)+c;
m[0][1] = y*x*(1-c)+z*s;
m[0][2] = x*z*(1-c)-y*s;
m[0][3] = 0;
m[1][0] = x*y*(1-c)-z*s;
m[1][1] = y*y*(1-c)+c;
m[1][2] = y*z*(1-c)+x*s;
m[1][3] = 0;
m[2][0] = x*z*(1-c)+y*s;
m[2][1] = y*z*(1-c)-x*s;
m[2][2] = z*z*(1-c)+c;
m[2][3] = 0;
m[3][0] = 0;
m[3][1] = 0;
m[3][2] = 0;
m[3][3] = 1;
}
I don't know what else is relevant, so, if you're kind enough to lend me a hand on this and if I just don't present enough info, just say it.
Thank you for taking the time to read this question.
EDIT
The trouble I'm having is the following: If I do Rotate (180,0,0,0), the vertexes are inverted as intended but the resulting triangle (in this case) is smaller. (Screenshot: http://imageshack.us/photo/my-images/855/10155684.png/)