Quantcast
Channel: "Average" of multiple quaternions? - Stack Overflow
Viewing all articles
Browse latest Browse all 17

Answer by consultit for "Average" of multiple quaternions?

$
0
0

This is my implementation in python of Tolga Birdal's algorithm:

import numpy as npdef quatWAvgMarkley(Q, weights):'''    Averaging Quaternions.    Arguments:        Q(ndarray): an Mx4 ndarray of quaternions.        weights(list): an M elements list, a weight for each quaternion.'''    # Form the symmetric accumulator matrix    A = np.zeros((4, 4))    M = Q.shape[0]    wSum = 0    for i in range(M):        q = Q[i, :]        w_i = weights[i]        A += w_i * (np.outer(q, q)) # rank 1 update        wSum += w_i    # scale    A /= wSum    # Get the eigenvector corresponding to largest eigen value    return np.linalg.eigh(A)[1][:, -1]

Viewing all articles
Browse latest Browse all 17

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>