5 % Modified: Mar 4, 2002
12 %slice = 4 % Image slice number
13 p = load('Kel_p9.dat'); %
Position vectors of rods
14 v = load(
'Kel_v9.dat'); % Direction vectors of rods
15 %
y = load(
'CRW_trs_y43_9.dat'); % Coordinates of fiducials on image plane
16 y = load(
'syn_y4_9.dat'); % Coordinates of fiducials on image plane
17 R0 = [0.9848 0.0000 -0.1736; 0.0000 1.0000 0.0000; 0.1736 0.0000 0.9848];
18 b0 = [19.3969 -20.0000 5.4202]
'; 19 N = size(p,2) % # of rods 23 R = eye(3); % Initial rotation matrix 24 %R = [-1 0 0; 0 0 1; 0 1 0]; % Initial rotation matrix 25 b = [5 5 5]'; % Initial translation vector
26 alpha = 1; % Positive constant
for (deldot) = -(
alpha)*(del)
27 delt = 0.1; % Time increment
30 error1 = zeros(limit, 1); % To store error at each iteration 31 error2 = zeros(limit, 2); % To store error at each iteration 33 % Calculation by iteration (velocity vector is calculated) 36 mat1 = zeros(3*N, 3*N); % Main equation is 37 mat2 = zeros(3*N, 6); % (mat1)*(mat2)*(l_vect) = (r_vect) 38 l_vect = zeros(6,1); % 6*1 velocity vector 39 r_vect = zeros(3*N, 1); 41 tmp1 = eye(3) - v(:,i) * v(:,i)'; % 3*3 block
42 mat1((3*
i-2):(3*
i), (3*
i-2):(3*
i)) = tmp1;
44 % Skew symmetric matrix corresponding to tmp2
45 mat2((3*
i-2):(3*
i), 1:3) = [0 -tmp2(3) tmp2(2); ...
46 tmp2(3) 0 -tmp2(1); -tmp2(2) tmp2(1) 0];
47 mat2((3*
i-2):(3*
i), 4:6) = -eye(3);
48 del = tmp1 * (
p(:,
i) - (tmp2 +
b));
49 r_vect((3*
i-2):(3*
i)) = -
alpha * del;
52 l_vect = inv(mat3
' * mat3) * (mat3' * r_vect);
53 ang_vel = l_vect(1:3); % Angular vecocity
58 tmp_e(:,
i) = (eye(3) -
v(:,i) * v(:,
i)') * ...
59 (
p(:,
i) - (
R *
y(:,
i) + b));
63 error2(
cnt, :) = [sqrt(6 - 2 * trace(R0' * R)) norm(b0 - b)]; % NOTE
83 figure(1) % error vs
# of iterations 84 plot(
iter, error,
'k-')
85 xlabel('Number of iterations')
87 %logerror = log(error);
88 %plot(
iter, logerror, 'k-')
89 %plot(
iter, logerror, 'k:')
90 %xlabel('Number of iterations')
92 %tit = sprintf('Algorithm 2
for 6*1 approach, slice %d', slice);
94 %legend('solid: synthetic
data', 'dotted: real
data')
To store error at each iteration Calculation by iteration cnt
Positive constant for(deldot)
Initial rotation matrix R
Initial rotation matrix b
Algorithm Minimization over Position
Algorithm Minimization over Orientation
Coordinates of fiducials on image plane R0
Initial translation vector alpha
Algorithm Minimization over and Arc lengths Sangyoon Lee clear all flops(0) % Loading data files %slice
To store error at each iteration error2
Direction vectors of rods y
Position vectors of rods v