Skip to content

Instantly share code, notes, and snippets.

@Ben1980
Last active March 5, 2019 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ben1980/93d2854642f074929f21433aa86b990f to your computer and use it in GitHub Desktop.
Save Ben1980/93d2854642f074929f21433aa86b990f to your computer and use it in GitHub Desktop.
size_t Particle::IDCounter = 0;
Particle::Particle()
: mass(0) {
id = IDCounter++;
}
Particle::Particle(double mass, const Vector2D &acceleration, const Vector2D &velocity, const Vector2D &position)
: mass(mass), acceleration(acceleration), velocity(velocity), position(position) {
assert(mass > 0);
id = IDCounter++;
}
bool Particle::operator==(const Particle &rhs) const {
return id == rhs.id;
}
bool Particle::operator!=(const Particle &rhs) const {
return !(rhs == *this);
}
const Vector2D &Particle::getAcceleration() const {
return acceleration;
}
void Particle::setAcceleration(const Vector2D &acceleration) {
Particle::acceleration = acceleration;
}
const Vector2D &Particle::getVelocity() const {
return velocity;
}
void Particle::setVelocity(const Vector2D &velocity) {
Particle::velocity = velocity;
}
const Vector2D &Particle::getPosition() const {
return position;
}
void Particle::setPosition(const Vector2D &position) {
Particle::position = position;
}
double Particle::getMass() const {
return mass;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment