# Get from

### Highlights from tolgabirdal/averaging_quaternions

• avg_quaternion_markley(Q)
by Tolga Birdal
• wavg_quaternion_markley(Q...
by Tolga Birdal
• test_avg_quat.m
Average 100 times
• View all files
5.0
5.0 | 3 ratings Rate this file 7 Downloads (last 30 days) File Size: 117 KB File ID: #40098 Version: 1.1

# tolgabirdal/averaging_quaternions

### Tolga Birdal (view profile)

30 Jan 2013 (Updated )

This function computes the average (mean) quaternion.

File Information
Description

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 F. Landis Merkley to calculate the average quaternion. The algorithm is explained by F. Landis Markley at:
http://www.acsu.buffalo.edu/~johnc/ave_quat07.pdf
For this particular implementation, I would also like to reference Mandar Harshe:
http://www-sop.inria.fr/members/Mandar.Harshe/knee-joint/html/index.html
While being basic and straightforward, this algorithm is compared with 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)

Required Products MATLAB
MATLAB release MATLAB 7.9 (R2009b)
09 Feb 2016 Tolga Birdal

### Tolga Birdal (view profile)

Dear Tobias,

Thank you for the remarks and comments.

The randomly generated qinit is always known to be positive. For the sake of comparisons using the sum of squared method, I wanted the signs to match. Assuming that the average quaternion result would not be very different from the mean of the random sampling, the signs should ideally match.

This is only done for the sake of comparison with qinit. Nothing else. If you could come up with a more fair metric, I would love to add that.

Finally, I agree that this not something I'm proud of : ) But nevertheless lets me to evaluate the quaternions, otherwise the element-wise difference might just be too large.

Comment only
09 Feb 2016 Tobias Hauber

### Tobias Hauber (view profile)

Hey, first i want to thank you for publicly offer this algorithm as Matlab methode. But i found something in your test file "test_avg_quat" that i dont understand. In line 25 you calculate the average Quaternion and in line 28 you just override it with the absolut value of this average. The absolut Quaternion or the representet Rotation is different to the before calculated average Rotation with the Markley Methode. Did you maybe want to invert the sign so that q=-q? That wouldnt chance the Rotation but the sign. Or what is the reason for taking the absolut value?

Thanks T.

02 Jun 2014 Mosong Cheng

### Mosong Cheng (view profile)

30 Jan 2014 sathish

### sathish (view profile)

30 Sep 2013 Tolga Birdal

### Tolga Birdal (view profile)

Note that on 2001 Claus Gramkow showed that the naive mean is in fact a fair approximation of rotations:
http://www.soest.hawaii.edu/wessel/courses/gg711/pdf/Gramkow_2001_JMIV.pdf

I think re-orthagonalization using SVD after a standard averaging would suffice most applications.

Comment only