34 minutes ago, scragglypoo said:As for local space and world space, I have read a * b is world space, but b * a is local space so that you don't need to create axis angles?
I've never heard of this. I guess it could work that way. I'm going to look into this because it sounds intriguing and would save a lot of computation in my code for local rotations. But rotation about an arbitrary axis is pretty complex. Maybe it simplifies way down if the axis isn't arbitrary? But anyway here's my C code for axis rotation:
matrix rotationAboutAxis(float angle, vector axis)
{
float x2 = axis.x*axis.x;
float y2 = axis.y*axis.y;
float z2 = axis.z*axis.z;
float a = (degToRad(angle))/2.0;
float s = sinf(a);
float c = cosf(a);
float s2 = s*s;
float sc = s*c;
matrix rot = matrixIdentity();
rot[0][0] = 1-2*(y2+z2)*s2;
rot[0][1] = 2*(axis.x*axis.y*s2+axis.z*sc);
rot[0][2] = 2*(axis.x*axis.z*s2-axis.y*sc);
rot[1][0] = 2*(axis.y*axis.x*s2-axis.z*sc);
rot[1][1] = 1-2*(z2+x2)*s2;
rot[1][2] = 2*(axis.y*axis.z*s2+axis.x*sc);
rot[2][0] = 2*(axis.z*axis.x*s2+axis.y*sc);
rot[2][1] = 2*(axis.z*axis.y*s2-axis.x*sc);
rot[2][2] = 1-2*(x2+y2)*s2;
return rot;
}