I'm working on an attitude control system in terms of quaternions, and i'm basing my approach on the book Space Vehicle Dynamics and Control (2nd ed.). If we consider a proportionate controller, i.e.
$$\mathbf{u} = -\mathbf{K}_p \mathbf{q}_e $$
it would seem logical to me to define the error quaternions to be the first three elements of
$$\begin{bmatrix} q_{1e} \\ q_{2e} \\ q_{3e} \\ q_{4e} \\ \end{bmatrix} = \begin{bmatrix} q_{1} \\ q_{2} \\ q_{3} \\ q_{4} \\ \end{bmatrix} - \begin{bmatrix} q_{1c} \\ q_{2c} \\ q_{3c} \\ q_{4c} \\ \end{bmatrix}$$
Where $q_i$ are the actual quaternions and $q_c$ are the desired (commanded) quaternions. Yet in the book, they instead define
$$\begin{bmatrix} q_{1e} \\ q_{2e} \\ q_{3e} \\ q_{4e} \\ \end{bmatrix} = \begin{bmatrix} q_{4c} & q_{3c} & -q_{2c} & -q_{1c} \\ -q_{3c} & q_{4c} & q_{1c} & -q_{2c} \\ q_{2c} & -q_{1c} & q_{4c} & -q_{3c} \\ q_{1c} & q_{2c} & q_{3c} & q_{4c}\\ \end{bmatrix}\begin{bmatrix} q_{1} \\ q_{2} \\ q_{3} \\ q_{4} \\ \end{bmatrix}$$
To me it seems like we do this because there are multiple possible quaternions that correspond to the same orientation, but I have not yet found a clear explanation for this. Can anyone enlighten me?