X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=course%2Fsemester2%2Fpprog%2Fassignment1%2Fnbody.h;fp=course%2Fsemester2%2Fpprog%2Fassignment1%2Fnbody.h;h=372320512778a1c2a214bac3304ca0f5c00d05b8;hb=1612d2449b7c9e4fa202adac00cda23700df44c7;hp=0000000000000000000000000000000000000000;hpb=4aead302e9872ec0a42724a61589275569c4e783;p=matches%2Fhonours.git diff --git a/course/semester2/pprog/assignment1/nbody.h b/course/semester2/pprog/assignment1/nbody.h new file mode 100644 index 00000000..37232051 --- /dev/null +++ b/course/semester2/pprog/assignment1/nbody.h @@ -0,0 +1,58 @@ +#ifndef _NBODY_H +#define _NBODY_H + +/** + * @file nbody.h + * @author Sam Moore (205030628) + * @purpose N-Body simulator: declarations of simulation related parameters + */ + +#define M_PI 3.14159265358979323846264338327950288 /* pi */ +#define G 6.67428E-11 +#define DELTA_T 0.05 +#define DIMENSIONS 3 +#define square(x) ((x)*(x)) + + +/** + * Structure to represent a single Body + * @param mass - Mass of the body + * @param x - Position vector (array) + * @param v - Velocity vector (array) + * @param F - Net force vector (array) + */ +typedef struct +{ + + double mass; + double x[DIMENSIONS]; + double v[DIMENSIONS]; + double F[DIMENSIONS]; + int colour; + +} Body; + +/** + * Structure to store an array of bodies, along with the size of the array + * @param N - Size of the array + * @param body - The array of bodies + */ +typedef struct +{ + unsigned N; + Body * body; + +} System; + +void Body_Print(Body * a); //Print body a +void Body_Force(Body * a, System * s); //Compute force on body a due to system of bodies s +void Body_Velocity(Body * a); //Compute velocity of body a +void Body_Position(Body * a); //Compute position of body a + +System * System_Init(char * fileName); //Initialise System (array of bodies) from a text file + +void System_Step(System * system); //Perform a single computation step for a System + + + +#endif //_NBODY_H