Example #1
0
def showPrincipal1(F):
    """Show the principal axes."""
    clear()
    C,I = inertia.inertia(F.f)
    GD.message("Center: %s" % C)
    GD.message("Inertia tensor: %s" % I)
    Iprin,Iaxes = inertia.principal(I)
    GD.debug("Principal Values: %s" % Iprin)
    GD.debug("Principal Directions:\n%s" % Iaxes)

    siz = F.dsize()
    H = Axes.scale(siz).affine(Iaxes.transpose(),C)
    Ax,Ay,Az = Iaxes[:,0],Iaxes[:,1],Iaxes[:,2]
    G = Formex([[C,C+Ax],[C,C+Ay],[C,C+Az]],3)
    draw([F,G,H])
    sleep(2)
    return C,I,Iprin,Iaxes
def showPrincipal():
    """Show the principal axes."""
    F = selection.check(single=True)
    if not F:
        return
    # compute the axes
    C,I = inertia.inertia(F.f)
    GD.message("Center of gravity: %s" % C)
    GD.message("Inertia tensor: %s" % I)
    Iprin,Iaxes = inertia.principal(I)
    GD.message("Principal Values: %s" % Iprin)
    GD.message("Principal Directions: %s" % Iaxes)
    data = (C,I,Iprin,Iaxes)
    # now display the axes
    siz = F.diagonal()
    H = unitAxes().scale(1.1*siz).affine(Iaxes.transpose(),C)
    A = 0.1*siz * Iaxes.transpose()
    G = Formex([[C,C+Ax] for Ax in A],3)
    draw([G,H])
    export({'principalAxes':H,'_principal_data_':data})
    return data