Space Comps
 All Classes Files Functions Variables
physics.h
1 #ifndef PHYSICS_H
2 #define PHYSICS_H
3 #include <math.h>
4 #include "particle.h"
5 #include "constants.h"
6 #include <boost/random.hpp>
7 
8 #define _USE_MATH_DEFINES
9 
15 class Physics
16 {
17 public:
23  Physics();
24  ~Physics();
25 
34 
42  bool isOrbital();
43 
51  virtual void updatePositionAndVelocity(Particle* p, int timestep) = 0;
52 
61  bool particlesOverlap(Particle* a, Particle* b);
62 
71  void resolveCollision(Particle* lP, Particle* rP, int timestep);
72 
82  std::valarray<double> getRelativeVelocity(Particle* a, Particle* b);
83 
92  double getMagnitude(std::valarray<double> vel);
93 
102  double calculateKE(Particle* p);
103 
112  virtual double calculatePE(Particle* p);
113 
118  virtual void initializeAcceleration(Particle* p){};
119 
129  double randDouble(double min, double max);
130 
140  double randGamma(double mean, double var);
141 
149  int randBit();
150 
151 protected:
152  bool orbital;
153  Particle* centerOfGravity;
154 
155  boost::mt19937 rng;
156 
157 };
158 
159 #endif // PHYSICS_H
virtual void initializeAcceleration(Particle *p)
NOT REALLY SURE.
Definition: physics.h:118
Physics()
Constructs a Physics object.
Definition: physics.cpp:5
std::valarray< double > getRelativeVelocity(Particle *a, Particle *b)
Returns the relative velocity between two Particles.
Definition: physics.cpp:92
void resolveCollision(Particle *lP, Particle *rP, int timestep)
Resolves a collision between two Particles.
Definition: physics.cpp:30
double randDouble(double min, double max)
Generates a random double within a given range.
Definition: physics.cpp:112
virtual double calculatePE(Particle *p)
Calculates the potential energy of a given Particle.
Definition: physics.cpp:107
virtual void updatePositionAndVelocity(Particle *p, int timestep)=0
Updates the position and velocity of a Particle.
bool isOrbital()
Boolean for if the system is orbiting.
Definition: physics.cpp:26
The Physics class.
Definition: physics.h:15
Definition: particle.h:12
double randGamma(double mean, double var)
Generates a random double within a given range.
Definition: physics.cpp:125
int randBit()
Generates a 0 or 1.
Definition: physics.cpp:133
Particle * getCenterOfGravity()
Returns the centerOfGravity.
Definition: physics.cpp:14
double calculateKE(Particle *p)
Calculates the kinetic energy of a given Particle.
Definition: physics.cpp:102
bool particlesOverlap(Particle *a, Particle *b)
Determines whether or not two Particles overlap.
Definition: physics.cpp:19
double getMagnitude(std::valarray< double > vel)
Returns the magnitude of a vector.
Definition: physics.cpp:97