Firstly, I have done much googling and checking other stackoverflow posts about this, but cannot get a working reply or a snippet of working code. Maths is not my strength.
I need to have a routine that takes a camera point (CX,CY,CZ) and rotate it about a lookat point (LX,LY,LZ) by three rotation angles (RX,RY,RZ). Using euler rotations leads to gimbal lock in some cases which I need to avoid. So I heard about using quaternions.
I found this to convert the rotations into a quaternion http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/index.htm
and this to convert from a quaternion back to euler XYZ rotations http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/index.htm
They seem to work fine, but I need to know how to use the quaternion to rotate the CX,CY,CZ around LX,LY,LZ and then return the new CX,CY,CZ without issues of gimbal lock.
There is so much out there about this, that I am sure a good explanation and snippet of code will help not only me but many others in the future.
So please help if you can. Many thanks.