-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParticle.h
More file actions
32 lines (23 loc) · 886 Bytes
/
Particle.h
File metadata and controls
32 lines (23 loc) · 886 Bytes
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
#pragma once
#include "Vec3.h"
typedef enum { PART_NEUTRON, PART_PROTON, PART_PHOTON } particle_type;
// Class implementing Particle abstract base class
class Particle {
protected:
bool dispose;
Vec3 collideFlex(Particle *);
public:
Vec3 pos, velocity, accel;
double radius;
Particle(Vec3 p = 0, Vec3 v = 0, Vec3 a = 0, double r = 0) : dispose(false), pos(p), velocity(v), accel(a), radius(r) { };
virtual ~Particle() {};
void collide(int, int, int, int);
void move(double dt);
double distance(const Particle *) const;
bool collided(Particle *other) const { return distance(other) <= ( radius + other->radius ); };
virtual Particle *collide(Particle *, bool = true);
virtual void ApplyForce(Particle *) = 0;
virtual int getColor() const = 0;
virtual particle_type getType() const = 0;
bool disposable() { return dispose; }
};