Skip to content

Question about the .principal_axes() outputs. Conflicts with document? #4778

Answered by orbeckst
XuyangTsin asked this question in Q&A
Discussion options

You must be logged in to vote

The code is for principal_axes() is straightforward

    def principal_axes(group, wrap=False):
        atomgroup = group.atoms
        e_val, e_vec = np.linalg.eig(atomgroup.moment_of_inertia(wrap=wrap))

        # Sort
        indices = np.argsort(e_val)[::-1]
        # Make transposed in more logical form. See Issue 33.
        e_vec = e_vec[:, indices].T

        # Make sure the right hand convention is followed
        if np.dot(np.cross(e_vec[0], e_vec[1]), e_vec[2]) < 0:
            e_vec *= -1

        return e_vec

and does exactly what its docs say: calculate eigenvalues and eigenvectors, then sort from highest to lowest eval.

If you look at wikipedia's List_of_3D_inertia_tensors

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@orbeckst
Comment options

Answer selected by RMeli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants