ahrs
ahrs copied to clipboard
Sandwich product of Quaternion normalizes rotating point
Class: Quaternion
A vector x
in 3D can be rotated with the methods rotate()
and to_DCM()
as:
q = Quaternion([1.0, 2.0, 3.0, 4.0])
x = [1.0, 2.0, 3.0]
# Build rotation R from q and multiply it with x
x1 = q.toDCM()@x # returns [1.8, 2., 2.6]
# Simplifies the operation above:
x2 = q.rotate(x) # also returns [1.8, 2., 2.6]
A product q*x*q.conj()
is called a sandwich product and it also rotates x
by a given q
, but cannot be performed because they are different types of data. So, multiply with x
as a pure quaternion.
x3 = q*Quaternion(x)*q.conj() # returns [0.4811, 0.5345, 0.6949]
This product is, however, normalized. As a solution, the two first methods are preferred, but a seamless sandwich product would be nice to have.