ref: c78d6569ac4950fbe2fd47d0d715f0620293f221
dir: /sys/src/games/galaxy/galaxy.h/
typedef struct QB QB; typedef struct Body Body; typedef struct Quad Quad; typedef struct Vector Vector; struct QB { union { Quad *q; Body *b; }; int t; }; struct Vector { double x, y; }; struct Body { Vector; Vector v, a, newa; double size, mass; Image *col; }; struct Quad { Vector; QB c[4]; double mass; }; #pragma varargck type "B" Body* struct { QLock; Body *a; int l, max; } glxy; struct { Quad *a; int l, max; } quads; #define π2 6.28318530718e0 enum { EMPTY, QUAD, BODY, }; Point orig; double G, θ, scale, ε, LIM, dt, dt²; Body ZB; QB space; Image *randcol(void); Point topoint(Vector); Vector tovector(Point); Body *body(void); void drawbody(Body*); Vector center(void); void glxyinit(void); int Bfmt(Fmt*); void readglxy(int); void writeglxy(int); void quadcalc(Body*, QB, double); int quadins(Body*, double); void growquads(void); void quadsinit(void); int stats; int quaddepth; int calcs; double avgcalcs; #define STATS(e) if(stats) {e} #define CHECKLIM(b, f) \ if(((f) = fabs((b)->x)) > LIM/2) \ LIM = (f)*2; \ if(((f) = fabs((b)->y)) > LIM/2) \ LIM = (f)*2