-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptimalRigidPose.m
More file actions
36 lines (23 loc) · 860 Bytes
/
OptimalRigidPose.m
File metadata and controls
36 lines (23 loc) · 860 Bytes
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
34
35
function [ Ropt, dopt, T_hom, T_hom_inv] = OptimalRigidPose(XT, YT)
%This function calculate rotation and translation between global system to
%the one defined by chest support.
%XT are the local coordinates of points P_i, i.e. in the cad model
%YT are the global coordinates of points P_i, i.e. as measured by the Phase Space
%they are expected to be organized as
%XT = [x1 y1 z1; x2 y2 z2; x3 y3 z3; x4 y4 z4]
X = XT';
Y = YT';
xbar = mean(XT)';
ybar = mean(YT)';
for i = 1:4
Xtilde(:,i) = X(:,i) - xbar;
Ytilde(:,i) = Y(:,i) - ybar;
end
Co = Ytilde*Xtilde';
[U, Sigma, V] = svd(Co);
NewSigma = [1 0 0; 0 1 0; 0 0 det(U*V')];
Ropt = U*NewSigma*V';
dopt = ybar - Ropt*xbar;
T_hom = [Ropt dopt; [0 0 0 1]]; %rotation from local to global
T_hom_inv = [Ropt' -Ropt'*dopt; [0 0 0 1]]; %rotation from global to local T_hom_inv = inv(T_hom)
end