“Average” of multiple quaternions?

前端 未结 13 1681
执念已碎
执念已碎 2020-12-12 17:31

I\'m trying to make the switch from matrices to quaternions for skeletal animation in my OpenGL program, but I\'ve encountered a problem:

Given a number of unit quat

13条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 17:54

    The easiest implementation (with Numpy in Python>=3.6) of Markley's solution would be:

    import numpy as np
    def q_average(Q, W=None):
        if W is not None:
            Q *= W[:, None]
        eigvals, eigvecs = np.linalg.eig(Q.T@Q)
        return eigvecs[:, eigvals.argmax()]
    

    where Q is of size N-by-4. The resulting quaternion is already normalized.

    In this case the weights are equal to 1 by default. Otherwise you can give a list of weights of size N (one per quaternion.)

    That's it.

提交回复
热议问题