//=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // Program stars //=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* #include "cip.h" #include "vector2.h" #include "nxgraph.h" //---- physical constants const double Mstar = 1.0; // mass of a star const double G = 1.0; // Gravity constant //---- experimental settings const double dT = 1.0/32; // time slice const int N = 4; // number of stars //---- graphic setting const int WIN_WIDTH = 256; const int WIN_HEIGHT = 256; const double MAG = 64.0; //---- declaration of structure Matter struct Matter { Vector2 p, q, f; // momentum, position, force }; //---- prototypes of functions void Init( Matter M[] ); void Evolve( Matter M[], double dt ); void CalcField( Matter M[] ); double CalcEnergy( Matter M[] ); void Draw( Matter M[] ); //---- main function int main( void ) { double T=0.0; Matter M[N]; NXOpenWindow("Dance of Stars", WIN_WIDTH, WIN_HEIGHT ); Init( M ); while( NXNoEvents() ){ Evolve( M, dT ); T += dT; Draw( M ); } NXCloseWindow(); return 0; } //---- initializes properties of stars void Init( Matter M[] ) { for( int n=0; n