#NEWLINE# def test_parallel_axis( ) : #NEWLINE# #INDENT# gravity = symbols ( 'g' ) #NEWLINE# ( k , ls ) = symbols ( 'k ls' ) #NEWLINE# ( a , mA , mC ) = symbols ( 'a mA mC' ) #NEWLINE# F = dynamicsymbols ( 'F' ) #NEWLINE# ( Ix , Iy , Iz ) = symbols ( 'Ix Iy Iz' ) #NEWLINE# ( q1 , q2 ) = dynamicsymbols ( 'q1 q2' ) #NEWLINE# ( q1d , q2d ) = dynamicsymbols ( 'q1 q2' , 1 ) #NEWLINE# ( u1 , u2 ) = dynamicsymbols ( 'u1 u2' ) #NEWLINE# ( u1d , u2d ) = dynamicsymbols ( 'u1 u2' , 1 ) #NEWLINE# N = ReferenceFrame ( 'N' ) #NEWLINE# A = ReferenceFrame ( 'A' ) #NEWLINE# A . orient ( N , 'Axis' , [ ( - q2 ) , N . z ] ) #NEWLINE# A . set_ang_vel ( N , ( ( - u2 ) * N . z ) ) #NEWLINE# O = Point ( 'O' ) #NEWLINE# C = O . locatenew ( 'C' , ( q1 * N . x ) ) #NEWLINE# Ao = C . locatenew ( 'Ao' , ( a * A . y ) ) #NEWLINE# O . set_vel ( N , 0 ) #NEWLINE# C . set_vel ( N , ( u1 * N . x ) ) #NEWLINE# Ao . v2pt_theory ( C , N , A ) #NEWLINE# Cart = Particle ( 'Cart' , C , mC ) #NEWLINE# Pendulum = RigidBody ( 'Pendulum' , Ao , A , mA , ( inertia ( A , Ix , Iy , Iz ) , C ) ) #NEWLINE# kindiffs = [ ( q1d - u1 ) , ( q2d - u2 ) ] #NEWLINE# bodyList = [ Cart , Pendulum ] #NEWLINE# forceList = [ ( Ao , ( ( ( - N . y ) * gravity ) * mA ) ) , ( C , ( ( ( - N . y ) * gravity ) * mC ) ) , ( C , ( ( ( - N . x ) * k ) * ( q1 - ls ) ) ) , ( C , ( N . x * F ) ) ] #NEWLINE# km = KanesMethod ( N , [ q1 , q2 ] , [ u1 , u2 ] , kindiffs ) #NEWLINE# with warnings . catch_warnings ( ) : #NEWLINE# #INDENT# warnings . filterwarnings ( 'ignore' , category = SymPyDeprecationWarning ) #NEWLINE# ( fr , frstar ) = km . kanes_equations ( forceList , bodyList ) #NEWLINE# #UNINDENT# mm = km . mass_matrix_full #NEWLINE# assert ( mm [ ( 3 , 3 ) ] == Iz )