mat4 rotationMatrix(vec3 axis, float angle) {

vec3 a = normalize(axis);

float s = sin(angle);

float c = cos(angle);

float oc = 1.0 – c;

float sx = s * a.x;

float sy = s * a.y;

float sz = s * a.z;

float ocx = oc * a.x;

float ocy = oc * a.y;

float ocz = oc * a.z;

float ocxx = ocx * a.x;

float ocxy = ocx * a.y;

float ocxz = ocx * a.z;

float ocyy = ocy * a.y;

float ocyz = ocy * a.z;

float oczz = ocz * a.z;

return mat4(

vec4(ocxx + c, ocxy – sz, ocxz + sy, 0.0),

vec4(ocxy + sz, ocyy + c, ocyz – sx, 0.0),

vec4(ocxz – sy, ocyz + sx, oczz + c, 0.0),

vec4( 0.0, 0.0, 0.0, 1.0)

);

}