Have done lot of googling on this and am overwhelmed by the number of formulas; not a math major, just a developer struggling to understand quaternion rotations:)
Given a vector of: 0, 0, 0.15
And a quaternion: 0.86671, -0.40654, -0.21285, 0.19555 (s, x, y, z)
Vector should equal: -0.07919, 0.09322, 0.08683
Any help to understand what formulas should be applied to get to this result is appreciated.
Formula
The formula to calculatise would be $$\mathrm{v}_{\text{rotated}} = \mathrm{q} \cdot \mathrm{v} \cdot \overline{\mathrm{q}}$$ with your vector $$\mathrm{v} = \left[\begin{matrix}0\\ 0\\ 0.15\end{matrix}\right] = 0 \cdot \mathrm{i} + 0 \cdot \mathrm{j} + 0.15 \cdot \mathrm{k}$$ and your quaternion $$\mathrm{q} = 0.86671 - 0.40654 \cdot \mathrm{i} - 0.21285 \cdot \mathrm{j} + 0.19555 \cdot \mathrm{k}$$ and $$\overline{\mathrm{q}} = 0.86671 + 0.40654 \cdot \mathrm{i} + 0.21285 \cdot \mathrm{j} - 0.19555 \cdot \mathrm{k}$$ with $\mathrm{i}^{2} = \mathrm{j}^{2} = \mathrm{k}^{2} = \mathrm{i} \cdot \mathrm{j} \cdot \mathrm{k} = -1$.
But don't forget that quaternions are not commutative with respect to multiplication.
Formula with roationangle and rotationaxis
If you use the vector / quaternion $r$ as the axis of rotation, $\varphi$ as the rotation angle, $\mathrm{v}$ as the vector to be rotated and the rotated vector $\mathrm{v}_{\text{rotated}}$, then the formula applies: $$ \begin{align*} \mathrm{v}_{\text{rotated}} &= \mathrm{q} \cdot \mathrm{v} \cdot \overline{\mathrm{q}}\\ \mathrm{v}_{\text{rotated}} &= \left( \cos\left( \frac{\varphi}{2} \right) + \mathrm{u} \cdot \sin\left( \frac{\varphi}{2} \right) \right) \cdot \mathrm{v} \cdot \left( \cos\left( \frac{\varphi}{2} \right) - \mathrm{u} \cdot \sin\left( \frac{\varphi}{2} \right) \right)\\ \mathrm{v}_{\text{rotated}} &= \left( \cos\left( \frac{\varphi}{2} \right) + \frac{\mathrm{r}}{||\mathrm{r}||} \cdot \sin\left( \frac{\varphi}{2} \right) \right) \cdot \mathrm{v} \cdot \left( \cos\left( \frac{\varphi}{2} \right) - \frac{\mathrm{r}}{||\mathrm{r}||} \cdot \sin\left( \frac{\varphi}{2} \right) \right)\\ \end{align*} $$
Code
Since you are a developer, my code for calculating rotation using quaternions might tell you more then the formulas:
HTML
JavaScript
CSS
free to use for everyone ;)