difference between 2 quaternions I'm trying to calculate quaternions relative to a given orientation. It is easiest for me to explain my intentions by means of an example:
Suppose you have a vector $v1=[0,0,1]$ and I want to rotate it so it becomes $v2=[-0.5774,-0.5774,-0.5774]$ (which is just the normalized version of [-1,-1,-1]). I can easily calculate this using $xyz = v1 \times v2$ and $w = v1 \cdot v2$. The resulting quaternion would be $q1 = [w, xyz]$.
Now my problem arises when I rotate $v1$ first with a quaternion $q_x$ which is unkown. Let $v1'$ ($= q_x * v1$) be the rotated version of $v1$. I would like to calculate the quaternion $q_\delta$ which can rotate $v1'$ so it becomes $v2$.
I had read on the internet (link) that I could do this as follows: $q_\delta = inv(q_x) * q_1$. This seemed plausible however, when I try it on the following example, the result is not correct.
example
suppose the unkown angle $q_x = [0.707, 0, 0.707, 0]$. This means that the vector $v1' = [1,0,0]$. If we calculate the quaternion $q_\delta$ according to the given formula we get $q_\delta = [-0.119, 0.444, -0.769, 0.444]$. Applying this $q_\delta$ to $v1'$ results in $[-0.577, -0.789, 0.211]$ instead of the wanted $v2 (= [-0.5774,-0.5774,-0.5774])$.
Can anyone help me out? Because I think I'm missing out on some basic quaternion pricinciple. Thanks
 A: The quaternion $q$ that will rotate $v_1$ to $v_2$, that is, will make $q*v_1 = v_2$, is $q= v_2 * v_1^{-1}$, where $v_1^*$ is the conjugate of $v_1$. But since $v_1$ in particular is a unit vector, $v_1^{-1} = \frac{v_1^*}{|v_1|^2} = \frac{-v_1}{1} = -v_1$. So $q = -v_2 * v_1$.
For any two quaternions $r, s$, where $r = r_s + r_v$ and $s = s_s + s_v$, where $r_s, s_s$ are scalars (real numbers) and $r_v, s_v$ are vectors, then
the product is given by
$$r * s = (r_ss_s - r_v \cdot s_v) + (s_sr_v + r_ss_v + r_v \times s_v)$$
So 
$$q = -v_2 * v_1 = -(-v_2\cdot v_1 + v_2 \times v_1) = v_1\cdot v_2 + v_1 \times v_2$$
which confirms the formula you gave. 
Now consider your second case: you need $q_\delta *(q_x * v_1) = v_2$. But quarternion multiplication is associative, so $(q_\delta * q_x)*v_1 = v_2$. So $q_\delta * q_x = q$, and so 
$$q_\delta * q_x * q_x^{-1}= q * q_x^{-1}$$
$$q_\delta * 1 = q * q_x^{-1}$$
$$q_\delta = q * q_x^{-1}$$
In your notation, $$q_\delta = q*\operatorname{inv}(q_x),$$ 
which also matches what was actually said in the post to which you linked:

diff * q1 = q2  --->  diff = q2 * inverse(q1)


Apparently, the basic quarternion principle you are missing is that multiplication of quaternions is not commutative. In general,
$$q*\operatorname{inv}(q_x) \ne \operatorname{inv}(q_x)*q$$
This can be seen from the formula for multiplication above if you recall that the cross-product is actually anti-commutative:
$$v_1 \times v_2 = - v_2 \times v_1$$
