-
Notifications
You must be signed in to change notification settings - Fork 9
/
quatInverse.m
31 lines (26 loc) · 1.19 KB
/
quatInverse.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
28
29
30
31
function q_inverse = quatInverse(q)
%‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
% [Eq. 13 Trawny]
% QUATINVERSE Takes the inverse of a given quaternion
% (N.B.: The inverse rotation is described by the inverse - or complex conjugate for unit quaternions -
% quaternion)
%
% INPUT:
% * q, Quaternion q(k) (q = [q0; q1; q2; q3], q0 is the scalar) (4 x 1) vector []
%
% OUTPUT:
% * q_inverse, (not unitary) Quaternion, inverse of q (4 x 1) vector []
%
% Author: Livio Bisogni
%_______________________________________________________________________________________________________
% Check number of arguments
narginchk(1,1);
if (~isequal(size(q), [4 1]))
error('q must be a (4 x 1) vector.');
end
q_inverse = [-q(1);
-q(2);
-q(3);
q(4)];
q_inverse = q_inverse / norm(q_inverse)^2;
end