Apologies if the title doesn’t quite make sense, it’s been a long time since I did any 3D stuff. I would like to be able to pan my camera up and down with the arrow keys. The camera’s rotation is described by a quaternion, and I need to rotate that quaternion around an imaginary axis orthogonal to the way the camera is pointing (if you can imagine the camera mounted on the front of a big + then the axis I need would be the horizontal bars).

I know how many radians I need to rotate by, but I’m struggling to work out how to get the axis I need to rotate around. I’ve tried to draw what I mean:

The red line is where my camera is actually facing. It (eventually) will be able to tilt left and right as well. The green line is “up” from where the camera is pointing, and the blue line is the axis I want to rotate around for up/down panning. Please try and imagine they’re all at right angles.

How do I rotate my quaternion *q* around the blue line by *r* number of radians? Is there something I can do with a matrix here and skip looking for an axis? If it helps I’m using g3n in golang so this is what I have to work with.