-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathparticle.cpp
116 lines (87 loc) · 1.73 KB
/
particle.cpp
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
#include "particle.h"
Particle::Particle()
{
position = vectorF(3, 0.f);
velocity = vectorF(3, 0.f);
force = vectorF(3, 0.f);
}
void Particle::reset()
{
position = vectorF(3, 0.f);
velocity = vectorF(3, 0.f);
force = vectorF(3, 0.f);
mass = 1.f;
lifetime = 0.f;
}
void Particle::setLifetime(float lifetime)
{
this->lifetime = lifetime;
}
void Particle::setMass(float mass)
{
this->mass = mass;
}
void Particle::setPosition(const vectorF& position)
{
this->position = position;
}
void Particle::setVelocity(const vectorF& velocity)
{
this->velocity = velocity;
}
void Particle::setForce(const vectorF& force)
{
this->force = force;
}
float Particle::getLifetime() const
{
return lifetime;
}
float Particle::getMass() const
{
return this->mass;
}
const Particle::vectorF& Particle::getPosition() const
{
return this->position;
}
const Particle::vectorF& Particle::getVelocity() const
{
return this->velocity;
}
const Particle::vectorF& Particle::getForce() const
{
return this->force;
}
Particle::vectorF& Particle::getPosition()
{
return this->position;
}
Particle::vectorF& Particle::getVelocity()
{
return this->velocity;
}
Particle::vectorF& Particle::getForce()
{
return this->force;
}
void Particle::atPosition(unsigned int index, float value)
{
position[index] = value;
}
void Particle::atVelocity(unsigned int index, float value)
{
velocity[index] = value;
}
float Particle::atPosition(unsigned index) const
{
return position[index];
}
float Particle::atVelocity(unsigned index) const
{
return position[index];
}
void Particle::print()
{
std::cout<<"Position: "<<position[0]<<", "<<position[1]<<", "<<position[2]<<std::endl;
}