I found this formula for rotating a vector by a quaternion on numpy-quaternion documentation.
v' = v + 2 * r x (s * v + r x v) / m
where x represents the cross product, s and r are the scalar and vector parts of the quaternion, respectively, and m is the sum of the squares of the components of the quaternion.
I need to know how this formula is derived and whether it is indeed equal to qvq'
Are there any other equations for rotating a vector from quaternion that is simpler to calculate? (The quaternions in my problem are always unit quaternions)
Thank you
That formula is known as Euler-Rodrigues Formula:
https://en.m.wikipedia.org/wiki/Euler-Rodrigues_formula
Which is just applying Euler parameters to the Rodrigues Formula. Since you can derive Rodrigues Formula from the quaternion product:
See for instance: Is there a relationship between Rotors and the Rodrigues' rotation formula
You only need to connect the Rodrigues Formula:
$v' = (\cos\theta) v + (\sin\theta) b \times v + (1 - \cos\theta) b ( b \cdot v )$
With:
$v' = v + 2 s (r \times v) + 2 r \times (r \times v)$
Using the fact that:
$\| b \| = 1$
$r = \sin(\theta/2) b$
$s = \cos(\theta/2)$
$r \times(r \times v) = r (r \cdot v) - v (r \cdot r)$
$r \cdot r = \| r \|^2 = \sin^2(\theta/2)$
$2 \sin^2(\theta/2) = 1 - \cos\theta$
$2 \cos(\theta/2) \sin(\theta/2) = \sin\theta$
REPLACING the above identities in $v' = v + 2 s (r \times v) + 2 r \times (r \times v)$ we get:
$v' = v + 2 \cos(\theta/2) \sin(\theta/2) b \times v + 2 \sin^2(\theta/2) b ( b \cdot v) - 2\sin^2(\theta/2) v$
Applying trigonometric identities:
$v' = v + (\sin\theta) b \times v + ( 1 - \cos\theta ) (b ( b \cdot v) - v)$
Rearranging terms:
$v' = (\cos\theta) v + (\sin\theta) b \times v + ( 1 - \cos\theta ) b ( b \cdot v)$
Which is the Rodrigues Formula.