<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> from sympy import Matrix <EOL> from sympy import pi , acos <EOL> from sympy import simplify , symbols <EOL> from sympy . physics . mechanics import ReferenceFrame , Point <EOL> from sympy . physics . mechanics import inertia , inertia_of_point_mass <EOL> from sympy . physics . mechanics import dot <EOL> def inertia_matrix ( dyadic , rf ) : <EOL> """<STR_LIT>""" <EOL> return Matrix ( [ [ dot ( dot ( dyadic , i ) , j ) for j in rf ] for i in rf ] ) <EOL> def angle_between_vectors ( a , b ) : <EOL> """<STR_LIT>""" <EOL> angle = ( acos ( dot ( a , b ) / ( a . magnitude ( ) * b . magnitude ( ) ) ) * <EOL> <NUM_LIT> / pi ) . evalf ( ) <EOL> return min ( angle , <NUM_LIT> - angle ) <EOL> m , m_R , m_C , rho , r = symbols ( '<STR_LIT>' , real = True , nonnegative = True ) <EOL> N = ReferenceFrame ( '<STR_LIT:N>' ) <EOL> pA = Point ( '<STR_LIT:A>' ) <EOL> pPs = pA . locatenew ( '<STR_LIT>' , <NUM_LIT:3> * r * N . x - <NUM_LIT:2> * r * N . y ) <EOL> m_R = rho * <NUM_LIT> * r ** <NUM_LIT:2> <EOL> m_C = rho * pi * r ** <NUM_LIT:2> <EOL> m = m_R - m_C <EOL> I_Cs_A = inertia_of_point_mass ( m , pPs . pos_from ( pA ) , N ) <EOL> I_C_Cs = inertia ( N , m_R * ( <NUM_LIT:4> * r ) ** <NUM_LIT:2> / <NUM_LIT:12> - m_C * r ** <NUM_LIT:2> / <NUM_LIT:4> , <EOL> m_R * ( <NUM_LIT:6> * r ) ** <NUM_LIT:2> / <NUM_LIT:12> - m_C * r ** <NUM_LIT:2> / <NUM_LIT:4> , <EOL> m_R * ( ( <NUM_LIT:4> * r ) ** <NUM_LIT:2> + ( <NUM_LIT:6> * r ) ** <NUM_LIT:2> ) / <NUM_LIT:12> - m_C * r ** <NUM_LIT:2> / <NUM_LIT:2> ) <EOL> I_C_A = I_C_Cs + I_Cs_A <EOL> print ( "<STR_LIT>" . format ( I_C_A ) ) <EOL> evecs_m = [ triple [ <NUM_LIT:2> ] <EOL> for triple in inertia_matrix ( I_C_A , N ) . eigenvects ( ) ] <EOL> evecs = [ sum ( simplify ( v [ <NUM_LIT:0> ] [ i ] ) . evalf ( ) * n for i , n in enumerate ( N ) ) <EOL> for v in evecs_m ] <EOL> print ( "<STR_LIT>" + <EOL> "<STR_LIT>" ) <EOL> for v in evecs : <EOL> print ( "<STR_LIT>" . format ( v , angle_between_vectors ( N . x , v ) ) ) </s>
