-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfromPosQuatToTransfMatr.m
33 lines (28 loc) · 1.01 KB
/
fromPosQuatToTransfMatr.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
32
33
function H = fromPosQuatToTransfMatr(q)
% FROMPOSQUATTOTRANSFMATRIX takes as input a pose (position + orientation)
% with orientation expressed in quaternions, and
% outputs the same pose in terms of transformation
% matrix.
%
% FORMAT: H = fromPosQuatToTransfMatr(q)
%
% INPUT: - q = [7 * 1] pose (position + quaternions)
%
% OUTPUT: - H = [4 * 4] pose (transformation matrix)
%
% Authors: Daniele Pucci, Marie Charbonneau, Gabriele Nava
%
% all authors are with the Italian Istitute of Technology (IIT)
% email: [email protected]
%
% Genoa, Dec 2017
%
%% --- Initialization ---
% extract the position
x = q(1:3);
% compute the rotation matrix
R = wbc.rotationFromQuaternion(q(4:7));
% compose the transformation matrix
H = [R, x;
[0 0 0 1]];
end