-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParticle Class.h
More file actions
executable file
·300 lines (279 loc) · 4.55 KB
/
Particle Class.h
File metadata and controls
executable file
·300 lines (279 loc) · 4.55 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#ifndef part
#define part
//#include "../include/vectors.h"
#include "vectors.h"
class particle
{
private:
vector2d<double> pos, vel;
double radius, mass, t_next;
int nextevent [2]; //ghostness indicated by index from 1 to 8 (0 if not ghost collision, see desktop background for further details), collisions labelled 1 to N, walls labelled -1,-2,-3,-4 (clockwise starting from top)
CGuiObject* myGuiObject;
int is_critical [5]; //shows if particle is over critical edge
public:
particle()
{
/* double snan = numeric_limits<double>::signaling_NaN();
pos = vector2d<double>(snan, snan);
pos = vector2d<double>(snan, snan);
radius = snan;
mass = snan;
t_next=1;
*/
pos = vector2d<double>(1, 1);
vel = vector2d<double>(1, 8.3);
radius = 1;
mass = 1;
t_next=1234;
}
particle(double x, double y, double z, double rad)
{
pos = vector2d<double>(x, y);
radius = rad;
mass = 0;
t_next=1;
}
particle(double x, double y, double rad)
{
pos = vector2d<double>(x, y);
radius = rad;
mass = 0;
t_next=1;
}
particle( const vector2d<double>& r, const vector2d<double>& v, double rad, double m)
{
pos = r;
vel = v;
radius = rad;
mass = m;
t_next=1;
}
particle(double x, double y, double z, double vx, double vy, double vz, double r, double m)
{
pos = vector2d<double>(x, y);
vel = vector2d<double>(vx, vy);
radius = r;
mass = m;
t_next=1;
}
particle(double x, double y, double vx, double vy, double r, double m)
{
pos = vector2d<double>(x, y);
vel = vector2d<double>(vx, vy);
radius = r;
mass = m;
t_next=1;
}
vector2d<double> getpos()
{
return pos;
}
double getx()
{
return pos.x();
}
double gety()
{
return pos.y();
}
double getz()
{
return 0.0;
}
vector2d<double> getvel()
{
return vel;
}
double getvelx()
{
return vel.x();
}
double getvely()
{
return vel.y();
}
double getvelz()
{
return 0.0;
}
double getrad()
{
return radius;
}
double getmass()
{
return mass;
}
double gett_next()
{
return t_next;
}
int getnextevent0()
{
return nextevent[0];
}
int getnextevent1()
{
return nextevent[1];
}
vector2d<double> getp()
{
return (vel*mass);
}
double getpx()
{
return (mass*vel.x());
}
double getpy()
{
return (mass*vel.y());
}
double getKE()
{
return (0.5 * mass * ( vel.mag() )*( vel.mag() ) );
}
int getCrit1()
{
return is_critical[1];
}
int getCrit2()
{
return is_critical[2];
}
int getCrit3()
{
return is_critical[3];
}
int getCrit4()
{
return is_critical[4];
}
//===========================set values of copies of particle==============================
void setx(double value)
{
double xcoord = value;
pos.setx(xcoord);
}
void sety(double value)
{
double ycoord = value;
pos.sety(ycoord);
}
void setz(double value)
{
// pos.setz(value);
}
void setpos(const vector2d<double>& r)
{
double xcoord = r.x(), ycoord = r.y();
pos = vector2d<double>(xcoord, ycoord);
}
void setpos(double x, double y)
{
pos = vector2d<double>(x, y);
}
void setvelx(double value)
{
vel.setx(value);
}
void setvely(double value)
{
vel.sety(value);
}
void setvelz(double value)
{
// vel.setz(value);
}
void setvel(const vector2d<double>& v)
{
vel = v;
}
void setvel(double vx, double vy)
{
vel = vector2d<double>(vx, vy);
}
void setvel(double r, double theta, char type)
{
vel = vector2d<double>(r*cos(theta), r*sin(theta) );
}
void setrad(double value)
{
radius = value;
}
void setmass(double value)
{
mass = value;
}
void setp(vector2d<double> momentum)
{
setvel(momentum/mass);
}
void sett_next(double t)
{
t_next=t;
}
void setnextevent(int nextcol [2])
{
nextevent[0]=nextcol[0];
nextevent[1]=nextcol[1];
}
void setnextevent(int el0, int el1)
{
nextevent[0]=el0;
nextevent[1]=el1;
}
CGuiObject* getGuiObject()
{
return myGuiObject;
}
void setGuiObject(CGuiObject* Ob)
{
myGuiObject = Ob;
}
void changeCrit1()
{
if(is_critical[1]==0)
{
is_critical[1]=1;
}
else if(is_critical[1]==1)
{
is_critical[1]=0;
}
}
void changeCrit2()
{
if(is_critical[2]==0)
{
is_critical[2]=1;
}
else if(is_critical[2]==1)
{
is_critical[2]=0;
}
}
void changeCrit3()
{
if(is_critical[3]==0)
{
is_critical[3]=1;
}
else if(is_critical[3]==1)
{
is_critical[3]=0;
}
}
void changeCrit4()
{
if(is_critical[4]==0)
{
is_critical[4]=1;
}
else if(is_critical[4]==1)
{
is_critical[4]=0;
}
}
//=============================other stuff===============================
};
#endif