The difference $\Delta q$ between two quaternions $q1$ and $q2$ can be calculated as $\Delta q = q1\cdot q2^{-1}$, where $^{-1}$ is the quaternion conjugate.
When numerically evaluating the difference, I observed that the difference depends on the initial 3D rotation. I denote $q(yaw, pitch, roll)$ the quaternion conversion from Euler angles to make it more visual. E.g.:
$q(10,10,130)\cdot q(20,20,120)^{-1} = [ 0.986, 0.119, -0.0191, 0.108]$
$q(40,20,130)\cdot q(50,30,120)^{-1} = [ 0.985, 0.116, -0.0149, 0.123]$
Both have a difference of $(-10,-10,10)$ in Euler angles, but there are significant differences in the quaternion values. For my application, the difference should be equal independent of the initial rotation, and I cannot use Euler angles, because they do not wrap around 360.
I have two questions now:
Why does the difference between two quaternions depend on the Euler angles and is not constant over the full rotation?
Is there a representation for 3D rotations, where the difference does not depend on the initial rotation?
The difference $\Delta q$ that you describe is equivalent to doing one rotation and then the second rotation in the reverse direction. This is not the same as the just subtracting the Euler angles so it is expected that they provide different results in general. Note that they yield the same results in some special cases, like when subtracting the rotation to itself.