Let's assume we have a plane (or a ship, does not matter). We have a GPS-receiver installed on our plane, e.g on a wing. So, how do we find position of a point (with known shifts from our receiver), if we know exact position (x, y, z) and roll/pitch/yaw at some time?
It's obvious, that rotation matrices are not applicable. I tried to solve this problem rotating the whole body around an axis, but it turned out, that this way I can take in account only two angles. However, I can be wrong.
Scilab solution:
pi = 3.15159265358979323;
trk = 45;
ptc = 0;
rll = 0;
track = (-trk)*pi/180; // minus because track is measured clockwize
pitch = (ptc)*pi/180; //
roll = (rll)*pi/180;
v0 = [1;1;1];
// 1
rot_ax = [0;0;1];
fi = track;
cofi = cos(fi);
sifi = sin(fi);
x = rot_ax(1);
y = rot_ax(2);
z = rot_ax(3);
M1 = [
cofi + (1 - cofi)*x*x , (1 - cofi)*x*y - sifi*z , (1 - cofi)*x*z + sifi*y ;
(1 - cofi)*y*x + sifi*z , cofi + (1 - cofi)*y*y , (1 - cofi)*y*z - sifi*x ;
(1 - cofi)*z*x - sifi*y , (1 - cofi)*z*y + sifi*x , cofi + (1 - cofi)*z*z
];
v1 = M1*v0;
// 2
rot_ax = [v1(2),-v1(1),0];
fi = pitch;
cofi = cos(fi);
sifi = sin(fi);
x = rot_ax(1);
y = rot_ax(2);
z = rot_ax(3);
M2 = [
cofi + (1 - cofi)*x*x , (1 - cofi)*x*y - sifi*z , (1 - cofi)*x*z + sifi*y ;
(1 - cofi)*y*x + sifi*z , cofi + (1 - cofi)*y*y , (1 - cofi)*y*z - sifi*x ;
(1 - cofi)*z*x - sifi*y , (1 - cofi)*z*y + sifi*x , cofi + (1 - cofi)*z*z
];
v2 = M2*v1;
// 3
rot_ax = [v2(1),v2(2),v2(3)];
fi = roll;
cofi = cos(fi);
sifi = sin(fi);
x = rot_ax(1);
y = rot_ax(2);
z = rot_ax(3);
M3 = [
cofi + (1 - cofi)*x*x , (1 - cofi)*x*y - sifi*z , (1 - cofi)*x*z + sifi*y ;
(1 - cofi)*y*x + sifi*z , cofi + (1 - cofi)*y*y , (1 - cofi)*y*z - sifi*x ;
(1 - cofi)*z*x - sifi*y , (1 - cofi)*z*y + sifi*x , cofi + (1 - cofi)*z*z
];
v3 = M3*v2;
Best Answer
So, it looks like I've finally found the solution and it's based on rotation matrix from axis and angle (wikipedia).
We have 3 deltas $[\Delta x,\Delta y,\Delta z]$ and three angles $\psi,\sigma,\theta$ for track, roll and pitch respectively. The idea is to carefully rotate 3 times.
I've included Scilab code in the question, though it's not very neat and commented.