30 Jan 2013
This function computes the average (mean) quaternion.
% Averaging Quaternions
% Since quaternions are not regular vectors, but rather representations
% of orientation, an average quaternion cannot just be obtained by taking
% a weighted mean. This function implements the work done by paper by
% F. Landis Merkley to calculate the average quaternion. The algorithm
% explained by F. Landis Markley at:
% For this particular implementation, I would also like to reference Mandar
% This algorithm is compared by rotqrmean from VoiceBox and found to
% produce quite similar results, yet it is more elegant, much simpler to
% implement and follow. (Though, there might be difference in signs)
% Usage :
% Q is an Mx4 matrix, where each row stores a quaternion to be averaged.
% In return, the function outputs Qavg, which is a single quaternion
% corresponding to the average.
% Tolga Birdal
% Form the symmetric accumulator matrix
A=q*q'+A; % rank 1 update
% Get the eigenvector corresponding to largest eigen value