Particle​ Simulation Documentation
Loading...
Searching...
No Matches
particle.h
Go to the documentation of this file.
1#ifndef PARTICLE_H
2#define PARTICLE_H
3
4#include <iostream>
5#include <deque>
6
7#include "array.h"
8
9class Particle {
10public:
11
12
13
26 const std::array<double, 3>& position,
27 const std::array<double, 3>& velocity,
28 const std::array<double, 3>& acceleration,
29 const double radius, const double mass,
30 const std::array<int, 3>& color,
31 const std::string& name = ""
32 );
33
39 std::array<double, 3> getPosition() const;
40
41
47 double getX() const;
48
54 double getY() const;
55
61 double getZ() const;
62
68 void setPosition(const std::array<double, 3>& position);
69
75 void setX(double x);
76
82 void setY(double y);
83
89 void setZ(double z);
90
96 std::array<double, 3> getVelocity() const ;
97
103 double getVX() const;
104
110 double getVY() const;
111
117 double getVZ() const;
118
124 void setVelocity(const std::array<double, 3>& velocity);
125
131 void setVX(double vx);
132
138 void setVY(double vy);
139
145 void setVZ(double vz);
146
152 std::array<double, 3> getAcceleration() const;
153
159 void setAcceleration(const std::array<double, 3>& acceleration);
160
166 void setAX(double ax);
167
173 void setAY(double ay);
174
180 void setAZ(double az);
181
187 double getRadius() const;
188
194 void setRadius(double radius);
195
201 double getMass() const;
202
208 void setMass(double mass);
209
215 std::array<int, 3> getColor() const;
216
222 void update(double deltaTime);
223
229 void addTrailPoint(const std::array<double, 3>& point);
230
236 const std::deque<std::array<double, 3>>& getTrail() const;
237
238private:
239 std::array<double, 3> m_position;
240 std::array<double, 3> m_velocity;
241 std::array<double, 3> m_acceleration;
242 double m_radius;
243 double m_mass;
244 std::array<int, 3> m_color;
245
246 std::deque<std::array<double, 3>> m_trail;
247 static constexpr size_t m_maxTrailLength = 5000;
248
249public:
250 const std::string m_name;
251};
252
253#endif
void setPosition(const std::array< double, 3 > &position)
Sets the position.
Definition particle.cpp:38
void update(double deltaTime)
Updates the particle.
Definition particle.cpp:68
double getRadius() const
Gets the radius.
Definition particle.cpp:60
double getX() const
Gets the x coordinate of the posision.
Definition particle.cpp:34
double getY() const
Gets the y coordinate of the posision.
Definition particle.cpp:35
std::array< double, 3 > m_position
Particle position (in m).
Definition particle.h:239
Particle(const std::array< double, 3 > &position, const std::array< double, 3 > &velocity, const std::array< double, 3 > &acceleration, const double radius, const double mass, const std::array< int, 3 > &color, const std::string &name="")
Initialize particle.
Definition particle.cpp:3
std::array< double, 3 > getAcceleration() const
Gets the acceleration.
Definition particle.cpp:53
void setAY(double ay)
Sets the y coordinate of the acceleration.
Definition particle.cpp:57
void setY(double y)
Sets the y coordinate of the position.
Definition particle.cpp:40
void setVZ(double vz)
Sets the z coordinate of the velocity.
Definition particle.cpp:51
void setVY(double vy)
Sets the y coordinate of the velocity.
Definition particle.cpp:50
std::array< double, 3 > m_velocity
Particle velocity (in m/s).
Definition particle.h:240
double getZ() const
Gets the y coordinate of the posision.
Definition particle.cpp:36
std::array< int, 3 > getColor() const
Gets the color.
Definition particle.cpp:66
void setMass(double mass)
Sets the mass.
Definition particle.cpp:64
double getVX() const
Gets the x coordinate of the velocity.
Definition particle.cpp:44
double m_radius
Particle radius (in m).
Definition particle.h:242
void setVX(double vx)
Sets the x coordinate of the velocity.
Definition particle.cpp:49
void setAcceleration(const std::array< double, 3 > &acceleration)
Sets the acceleration.
Definition particle.cpp:55
void setAX(double ax)
Sets the x coordinate of the acceleration.
Definition particle.cpp:56
void setAZ(double az)
Sets the z coordinate of the acceleration.
Definition particle.cpp:58
double getVZ() const
Gets the z coordinate of the velocity.
Definition particle.cpp:46
std::array< double, 3 > getVelocity() const
Gets the velocity.
Definition particle.cpp:43
const std::deque< std::array< double, 3 > > & getTrail() const
Gets the trail.
Definition particle.cpp:82
void setRadius(double radius)
Sets the radius.
Definition particle.cpp:61
void setVelocity(const std::array< double, 3 > &velocity)
Sets the velocity.
Definition particle.cpp:48
void setZ(double z)
Sets the z coordinate of the position.
Definition particle.cpp:41
void setX(double x)
Sets the x coordinate of the position.
Definition particle.cpp:39
std::array< double, 3 > m_acceleration
Particle acceleration (in m/s²).
Definition particle.h:241
double getMass() const
Gets the mass.
Definition particle.cpp:63
double getVY() const
Gets the y coordinate of the velocity.
Definition particle.cpp:45
std::deque< std::array< double, 3 > > m_trail
trail particle.
Definition particle.h:246
const std::string m_name
particle name.
Definition particle.h:250
std::array< double, 3 > getPosition() const
Gets the position.
Definition particle.cpp:33
std::array< int, 3 > m_color
Particle colors.
Definition particle.h:244
static constexpr size_t m_maxTrailLength
max trail particle length.
Definition particle.h:247
double m_mass
Particle mass (in kg).
Definition particle.h:243
void addTrailPoint(const std::array< double, 3 > &point)
Adds a trail point.
Definition particle.cpp:76