% express the difference between two attitude quaternions
% as a LoS err w.r.t. the first one
% Err reported at x,y offset, radians, and camera twist, radians
function [de,dn,twist]=dq2losErr(q0,q)
% small angle assumtion, angle ~= sin(angle)
dcm0=quat2rot(q0); % (:,1) is LoS
dcm1=quat2rot(q);
dn=-dot(dcm0(:,2),dcm1(:,1)); % (:,2) is to-south in our standard
de= dot(dcm0(:,3),dcm1(:,1)); % east on our standard coords,
twist = dot(dcm0(:,2),dcm1(:,3)); % project one axis onto another, sin of angle between. small angle.
end