#NEWLINE# def euler( self ) : #NEWLINE# #INDENT# self . count += 1 #NEWLINE# distM = self . distM . copy ( ) #NEWLINE# disM = ( self . springM - distM ) #NEWLINE# disM = disM . reshape ( 64 , 1 ) #NEWLINE# distM = ( distM + 1e-10 ) #NEWLINE# vel = ( self . difM / distM ) #NEWLINE# vel *= ( ( disM * self . d ) * self . dt ) #NEWLINE# idx2 = arange ( 8 ) #NEWLINE# for i in range ( 8 ) : #NEWLINE# #INDENT# self . vel [ i ] += vel [ ( idx2 + ( i * 8 ) ) , : ] . sum ( axis = 0 ) #NEWLINE# #UNINDENT# self . vel += ( self . gravVect * self . dt ) #NEWLINE# self . vel -= ( ( self . vel * self . dumping ) * self . dt ) #NEWLINE# self . pos += ( self . dt * self . vel ) #NEWLINE# for i in range ( 8 ) : #NEWLINE# #INDENT# if ( self . pos [ i ] [ 1 ] < 0.0 ) : #NEWLINE# #INDENT# self . pos [ i ] [ 1 ] = 0.0 #NEWLINE# self . vel [ i ] = ( disM . vel [ i ] * [ 0.0 , ( - 1.0 ) , 0.0 ] ) #NEWLINE# #UNINDENT# #UNINDENT# self . centerOfGrav = ( self . pos . sum ( axis = 0 ) / 8.0 ) #NEWLINE# idx0 = arange ( 8 ) . repeat ( 8 ) #NEWLINE# idx1 = array ( ( list ( range ( 8 ) ) * 8 ) ) #NEWLINE# self . difM = ( self . pos [ idx0 , : ] - self . pos [ idx1 , : ] ) #NEWLINE# self . distM = sqrt ( ( self . difM ** 2 ) . sum ( axis = 1 ) ) . reshape ( 64 , 1 )