Code covered by the BSD License  

Highlights from
Averaging Quaternions

Averaging Quaternions



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
% Harshe:
% 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

function [Qavg]=avg_quaternion_markley(Q)

% Form the symmetric accumulator matrix

for i=1:M
    A=q*q'+A; % rank 1 update

% scale

% Get the eigenvector corresponding to largest eigen value
[Qavg, Eval]=eigs(A,1);


Contact us