// Particles... #include "Particles.h" // ------------------------------------------------------------ Vector Velocity( Particle P ) { return( ScalarVector( 1.0 / P.m, P.p ) ); } // ------------------------------------------------------------ double KineticEnergy( Particle P ) { return( 0.5 * DotVectors( P.p, P.p ) / P.m ); } // ------------------------------------------------------------ double TotalKineticEnergy( int N, Particle P[] ) { double K = 0.0; int i; for( i = 0; i < N; ++i ) K += KineticEnergy( P[ i ] ); return( K ); } // ------------------------------------------------------------ Vector CenterOfMass( int N, Particle P[] ) { Vector R = { 0.0, 0.0, 0.0 }; double Mass = 0.0; int i; for( i = 0; i < N; ++i ) { R = AddVectors( R, ScalarVector( P[ i ].m, P[ i ].r ) ); Mass += P[ i ].m; } return( ScalarVector( 1.0 / Mass, R ) ); } // ------------------------------------------------------------ void PrintParticle( Particle P ) { printf( "r.X: %lE, r.Y: %lE, r.Z: %lE, p.X: %lE, p.Y: %lE, p.Z: %lE, F.X: %lE, F.Y: %lE, F.Z: %lE, m: %lE\n", P.r.X, P.r.Y, P.r.Z, P.p.X, P.p.Y, P.p.Z, P.F.X, P.F.Y, P.F.Z, P.m ); } // ------------------------------------------------------------