5.1.1.2.4 : Summary Particle.cpp


Here is the full Particle.cpp file :

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
/***************************************
	Auteur : Pierre Aubert
	Mail : pierre.aubert@lapp.in2p3.fr
	Licence : CeCILL-C
****************************************/

#include "Particle.h"

///Default constructeur of Particle
Particle::Particle(){
	initialisationParticle();
}

///Copy constructor of Particle
/**	@param other : class to copy
*/
Particle::Particle(const Particle & other){
	copyParticle(other);
}

///Destructeur of Particle
Particle::~Particle(){
	
}

///Definition of equal operator of Particle
/**	@param other : class to copy
 * 	@return copied class
*/
Particle & Particle::operator = (const Particle & other){
	copyParticle(other);
	return *this;
}

///Initialise randomly the Particle
void Particle::randomInit(){
	float boxHalfSize(1.0f), velocity(0.005f);
	p_position.setComposante(randfloat(-boxHalfSize, boxHalfSize), randfloat(-boxHalfSize, boxHalfSize), randfloat(-boxHalfSize, boxHalfSize));
	p_velocity.setComposante(randfloat(-velocity, velocity), randfloat(-velocity, velocity), randfloat(-velocity, velocity));
	p_acceleration.setComposante(0.0f, 0.0f, -9.81f);
}

///Move the current Particle
/**	@param dt : ellapsed time
*/
void Particle::move(float dt){
	p_velocity += p_acceleration*dt;
	p_position += p_velocity*dt;
}

///Set the position of the Particle
/**	@param position : position of the Particle
*/
void Particle::setPosition(const Vec3f & position){
	p_position = position;
}

///Set the position of the Particle
/**	@param velocity : velocity of the Particle
*/
void Particle::setVelocity(const Vec3f & velocity){
	p_velocity = velocity;
}

///Set the position of the Particle
/**	@param acceleration : acceleration of the Particle
*/
void Particle::setAcceleration(const Vec3f & acceleration){
	p_acceleration = acceleration;
}

///Get the position of the Particle
/**	@return position of the Particle
*/
const Vec3f & Particle::getPosition() const{return p_position;}

///Get the position of the Particle
/**	@return position of the Particle
*/
Vec3f & Particle::getPosition(){return p_position;}

///Get the velocity of the Particle
/**	@return velocity of the Particle
*/
const Vec3f & Particle::getVelocity() const{return p_velocity;}

///Get the velocity of the Particle
/**	@return velocity of the Particle
*/
Vec3f & Particle::getVelocity(){return p_velocity;}

///Get the acceleration of the Particle
/**	@return acceleration of the Particle
*/
const Vec3f & Particle::getAcceleration() const{return p_acceleration;}

///Get the acceleration of the Particle
/**	@return acceleration of the Particle
*/
Vec3f & Particle::getAcceleration(){return p_acceleration;}

///Copy function of Particle
/**	@param other : class to copy
*/
void Particle::copyParticle(const Particle & other){
	p_position = other.p_position;
	p_velocity = other.p_velocity;
	p_acceleration = other.p_acceleration;
}

///Initialisation function of the class Particle
void Particle::initialisationParticle(){
	
}


You can download it here.