-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParticle.cpp
More file actions
27 lines (23 loc) · 746 Bytes
/
Particle.cpp
File metadata and controls
27 lines (23 loc) · 746 Bytes
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
#include "Particle.h"
using namespace std;
Particle::Particle(double mass, Vector2 initialPos, Vector2 initialVel,
double exclusionDistance, double potentialMin, ParticleType type)
: Mass(mass), Position(initialPos), Velocity(initialVel),
ExclusionDistance(exclusionDistance), PotentialMin(potentialMin), Type(type)
{ }
void Particle::AddForce(const Vector2& force)
{
_force = _force + force;
}
void Particle::Move(double dt)
{
Velocity = Velocity + _force / Mass * dt;
Position = Position + Velocity * dt;
_force = Vector2::NullVector();
}
bool Particle::operator==(const Particle& p) const
{
return (Mass == p.Mass)
&& (Position == p.Position)
&& (Velocity == p.Velocity);
}