-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon.h
90 lines (80 loc) · 1.88 KB
/
common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef __CS267_COMMON_H__
#define __CS267_COMMON_H__
inline int min( int a, int b ) { return a < b ? a : b; }
inline int max( int a, int b ) { return a > b ? a : b; }
//
// saving parameters
//
const int NSTEPS = 1000;
const int SAVEFREQ = 10;
//
// particle data structure
//
typedef struct
{
double x;
double y;
double vx;
double vy;
double ax;
double ay;
} particle_t;
//
// QuadTree data structure
//
class QuadTreeNode
{
public:
QuadTreeNode(QuadTreeNode* parent, double x, double y,
double width, double height, float theta);
~QuadTreeNode();
void insert(particle_t* p);
void computeCOM();
void computeF(particle_t* p, double* dmin, double* davg, int* navg);
void init_particles(particle_t* p, int n);
private:
particle_t* p;
double m;
double com_x;
double com_y;
double width;
double height;
float theta;
double x;
double y;
double wn;
double hn;
double xmid;
double ymid;
bool external;
QuadTreeNode* NW;
QuadTreeNode* NE;
QuadTreeNode* SW;
QuadTreeNode* SE;
QuadTreeNode* parent;
};
//
// timing routines
//
double read_timer( );
//
// simulation routines
//
double set_size( int n );
void init_particles( int n, particle_t *p );
void apply_force( particle_t &particle, particle_t &neighbor,
double *dmin, double *davg, int *navg);
void move( particle_t &p );
//
// I/O routines
//
FILE *open_save( char *filename, int n );
void save( FILE *f, int n, particle_t *p );
//
// argument processing routines
//
int find_option( int argc, char **argv, const char *option );
int read_int( int argc, char **argv, const char *option, int default_value );
char *read_string( int argc, char **argv, const char *option,
char *default_value );
#endif