-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathparticle.h
54 lines (40 loc) · 1.15 KB
/
particle.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
#ifndef PARTICLE_H
#define PARTICLE_H
#include <iostream>
#include <vector>
class Particle
{
//aliases
using vectorF = std::vector<float>;
const float INF = -1.f; //infinite
public:
Particle();
void reset();
void setLifetime(float lifetime);
void setMass(float mass);
void setPosition(const vectorF& position);
void setVelocity(const vectorF& velocity);
void setForce(const vectorF& force);
float getMass() const;
const vectorF& getPosition() const;
const vectorF& getVelocity() const;
const vectorF& getForce() const;
//provide a fast way to modify member vectors
vectorF& getPosition();
vectorF& getVelocity();
vectorF& getForce();
//Modify member vectors elements, it could be slow
void atVelocity(unsigned index, float value);
void atPosition(unsigned index, float value);
float atVelocity(unsigned index) const;
float atPosition(unsigned index) const;
float getLifetime() const;
void print();
private:
vectorF position;
vectorF velocity;
vectorF force;
float mass = 1.f;
float lifetime = INF; //milliseconds,
};
#endif // PARTICLE_H