I have some acceleration data collected from a bike ride. It still has gravity in it because I want to align the z-axis of my phone to the z-axis of the real world. The phone was mounted nearly parallel to the ground.
(The other two axis don't have to be matched to the other axis, since there seem to be some problems with only the accelerationdata.)
To get the Rotationmatrix I computed:
a_x = mean(data(:,1));
a_y = mean(data(:,2));
a_z = mean(data(:,3)); and defined
a = [a_x;a_y;a_z];
z = [0;0;1];
R=fcn_RotationFromTwoVectors(a,z);
and put it in the function
function R=fcn_RotationFromTwoVectors(A,B)
v = cross(A,B);
ssc = [0 -v(3) v(2);v(3) 0 -v(1); -v(2) v(1) 0];
R = eye(3) + ssc + ssc^2*(1-dot(A,B))/(norm(v))^2;
end
which calculates the Rotationmatrix. However when I compute
data_calib = rot90(R*data');
it seems that the data is aligned but also multiplied by some weired factor. What am I missing or doing wrong ?