#ifndef GRAVITY_SUPPORT_H_INCLUDED
#define GRAVITY_SUPPORT_H_INCLUDED


#define NMAX            100         /* max no. of bodies in simulation */
#define NDIMS           3           /* no. of space dimensions */
#define NAMELENGTH      20          /* length of name of a body */

typedef char   Identifier[NAMELENGTH+1];
typedef double VECTOR[NDIMS];


typedef struct {
          Identifier name;
          double     mass;
          VECTOR     position;
          VECTOR     velocity;
        } Body;

typedef struct {
          double Time;
          int    n;     /* no. of bodies; should be 0 to NMAX */
          Body   bodydata[NMAX];
        } STATE;


/*
for the time-derivative ("dot") types, we only bother with the parts that
change, and n for completeness of course.
*/
typedef struct {
          VECTOR position_dot;
          VECTOR velocity_dot;
        } Body_dot;

typedef struct {
          int      n;	/* no. of bodies; should be 0 to NMAX */
          Body_dot bodydata[NMAX];
        } STATE_DOT;




/* low-level functions. */

extern void CreateZeroVector (VECTOR Vresult);
extern double lengthsquared (VECTOR V);

extern void copy_state (STATE *state1, STATE *state2);
/*
treats *state1 as read-only; copies *state1 to *state2.
Assumes "static" parts of *state2 are already filled in.
*/

extern void incr_state (STATE *state, double delta_t, STATE_DOT *speed);
/* treats *speed as read-only; does "state = state + delta_t * speed". */




#endif /* GRAVITY_SUPPORT_H_INCLUDED */
