0

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 ?

bennnil
  • 15
  • 1
  • 5
  • 1
    How does the function `fcn_RotationFromTwoVectors` even work, given `a` and `z` are the only parameters, but you're using variables `A` and `B` within the function without prior assignment? – HansHirse Mar 06 '19 at 20:08
  • I am sorry, I mixed it up I changed it in the question. – bennnil Mar 08 '19 at 08:22

1 Answers1

1

Just found out by myself, that I had to use a unit vector - a is of course non. Just had to use unit_a

unit_a = a/norm(a);

now everything works as planned.

bennnil
  • 15
  • 1
  • 5