5.1.2.1.1 : Implementation table_particle.h
Implementation of table_particle.h file : First, we have to avoid multiple include :

1
2
#ifndef __TABLE_PARTICLE_H__
#define __TABLE_PARTICLE_H__


And use some basic include :

1
#include <iostream>


Then, we define a struct which will contain all the particles we want to simulate but we will split the different caracteristics of the particles in different tables (position, velocity, acceleration) :

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
///@brief Table of particles
struct TableParticle{
	///Number of particles
	size_t nbParticle;
	///Table of the x position of the particles
	float * tabPosX;
	///Table of the y position of the particles
	float * tabPosY;
	///Table of the z position of the particles
	float * tabPosZ;
	
	///Table of the x velocity of the particles
	float * tabVitX;
	///Table of the y velocity of the particles
	float * tabVitY;
	///Table of the z velocity of the particles
	float * tabVitZ;
	
	///Table of the x acceleration of the particles
	float * tabAccX;
	///Table of the y acceleration of the particles
	float * tabAccY;
	///Table of the z acceleration of the particles
	float * tabAccZ;
};


Then we need to define a function to allocate the table of particles :

1
void allocTableParticle(TableParticle & tp, size_t nbParticle);


We need also to define a function to intialise the table of particles :

1
void initTableParticle(TableParticle & tp);


A function to free the table of particles :

1
void freeTableParticle(TableParticle & tp);


And finaly a function to move the particles :

1
void moveParticle(TableParticle & tp, float dt);


So we can close the ifndef :

1
#endif