forked from QIJINCHEN/IMA-estimation
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathquatprod.m
27 lines (26 loc) · 971 Bytes
/
quatprod.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function q = quatprod(q1, q2)
% -------------------------------------------------------------------------
%QUATPROD Quaternion product
% q = quatprod(q1, q2)
%
%INPUTS:
% q1, q2 = input quaternion
%OUTPUTS:
% q = output quaternion
%
% Reference: D. H. Titterton and J. L. Weston, Strapdown Inertial Navigation Technology, 2nd ed.
% Stevenage, U.K: IET, 2004. pp.43
% -------------------------------------------------------------------------
% Author:
% Qijin Chen, GNSS Research Center, Wuhan University, China.;
% Nov. 2019;
% -------------------------------------------------------------------------
q = [ q1(1) * q2(1) - q1(2) * q2(2) - q1(3) * q2(3) - q1(4) * q2(4);
q1(1) * q2(2) + q1(2) * q2(1) + q1(3) * q2(4) - q1(4) * q2(3);
q1(1) * q2(3) + q1(3) * q2(1) + q1(4) * q2(2) - q1(2) * q2(4);
q1(1) * q2(4) + q1(4) * q2(1) + q1(2) * q2(3) - q1(3) * q2(2) ];
if q(1) < 0
q = -q;
end
end