1 function q = AttiudeFromVectors(mag,north,accel)
2 % q = AttiudeFromVectors(mag,north,accel)
5 ge = ge / sqrt(ge' * ge);
6 mag = mag / sqrt(mag' * mag);
7 north = north / sqrt(north' * north);
8 accel = accel / sqrt(accel' * accel);
11 Rib(2,:) = cross(mag,accel);
12 Rib(3,:) = cross(Rib(1,:),Rib(2,:));
15 Rie(2,:) = cross(north,ge);
16 Rie(3,:) = cross(Rie(1,:),Rie(2,:));
20 m = [1 + R(1,1) + R(2,2) + R(3,3); ...
21 1 + R(1,1) - R(2,2) - R(3,3); ...
22 1 - R(1,1) + R(2,2) - R(3,3); ...
23 1 - R(1,1) - R(2,2) + R(3,3)];
30 (R(2,3)-R(3,2))/mag; ...
31 (R(3,1)-R(1,3))/mag; ...
35 q(1) = (R(2,3)-R(3,2))/mag;
36 q(3) = (R(1,2)+R(2,1))/mag;
37 q(4) = (R(1,3)+R(3,1))/mag;
40 q(1) = (R(3,1)-R(1,3))/mag;
41 q(2) = (R(1,2)+R(2,1))/mag;
42 q(4) = (R(2,3)+R(3,2))/mag;
45 q(1) = (R(1,2)-R(2,1))/mag;
46 q(2) = (R(1,3)+R(3,1))/mag;
47 q(3) = (R(2,3)+R(3,2))/mag;