Space Comps
 All Classes Files Functions Variables
Public Member Functions | Protected Attributes | List of all members
Physics Class Referenceabstract

The Physics class. More...

#include <physics.h>

Inheritance diagram for Physics:
OrbitalPhysics Physics2D Physics3D

Public Member Functions

 Physics ()
 Constructs a Physics object. More...
 
ParticlegetCenterOfGravity ()
 Returns the centerOfGravity. More...
 
bool isOrbital ()
 Boolean for if the system is orbiting. More...
 
virtual void updatePositionAndVelocity (Particle *p, int timestep)=0
 Updates the position and velocity of a Particle. More...
 
bool particlesOverlap (Particle *a, Particle *b)
 Determines whether or not two Particles overlap. More...
 
void resolveCollision (Particle *lP, Particle *rP, int timestep)
 Resolves a collision between two Particles. More...
 
std::valarray< double > getRelativeVelocity (Particle *a, Particle *b)
 Returns the relative velocity between two Particles. More...
 
double getMagnitude (std::valarray< double > vel)
 Returns the magnitude of a vector. More...
 
double calculateKE (Particle *p)
 Calculates the kinetic energy of a given Particle. More...
 
virtual double calculatePE (Particle *p)
 Calculates the potential energy of a given Particle. More...
 
virtual void initializeAcceleration (Particle *p)
 NOT REALLY SURE. More...
 
double randDouble (double min, double max)
 Generates a random double within a given range. More...
 
double randGamma (double mean, double var)
 Generates a random double within a given range. More...
 
int randBit ()
 Generates a 0 or 1. More...
 

Protected Attributes

bool orbital
 
ParticlecenterOfGravity
 
boost::mt19937 rng
 

Detailed Description

The Physics class.

The Physics class; parent of Physics2D, Physics3D, and OrbitalPhysics.

Constructor & Destructor Documentation

Physics::Physics ( )

Constructs a Physics object.

Constructs a Physics object by setting Orbital to false and seeding random number generators.

Member Function Documentation

double Physics::calculateKE ( Particle p)

Calculates the kinetic energy of a given Particle.

Returns a double representing the kinetic energy given a pointer to a Particle.

Parameters
ppointer to a Particle
Returns
double
double Physics::calculatePE ( Particle p)
virtual

Calculates the potential energy of a given Particle.

Returns a double representing the potential energy given a pointer to a Particle.

Parameters
ppointer to a Particle
Returns
double

Reimplemented in OrbitalPhysics.

Particle * Physics::getCenterOfGravity ( )

Returns the centerOfGravity.

Returns a pointer to a Particle representing the centerOfGravity.

Returns
pointer to a Particle.
double Physics::getMagnitude ( std::valarray< double >  vel)

Returns the magnitude of a vector.

Returns a double representing the magnitude of a given std::valarray<double>.

Parameters
velstd::valarray<double>
Returns
double
std::valarray< double > Physics::getRelativeVelocity ( Particle a,
Particle b 
)

Returns the relative velocity between two Particles.

Returns a std::valarray<double> of the relative velocity between two Particles given a pointer to each Particle.

Parameters
apointer to first Particle
bpointerto second Particle
Returns
std::valarray<double>
virtual void Physics::initializeAcceleration ( Particle p)
inlinevirtual

NOT REALLY SURE.

Parameters
ppointer to a Particle
bool Physics::isOrbital ( )

Boolean for if the system is orbiting.

Returns true if the system has orbiting Particles; false if not.

Returns
boolean
bool Physics::particlesOverlap ( Particle a,
Particle b 
)

Determines whether or not two Particles overlap.

Returns a bool true if the two Particles overlap, otherise false.

Parameters
apointer to the first Particle.
bpointer to the second Particle.
Returns
bool whether or not the Particles overlap.
int Physics::randBit ( )

Generates a 0 or 1.

Returns 0 or 1 randomly generated in a normal distribution.

Returns
int
double Physics::randDouble ( double  min,
double  max 
)

Generates a random double within a given range.

Returns a randomly generated double in a normal distribution between a given min and max.

Parameters
mindouble
maxdouble
Returns
double
double Physics::randGamma ( double  mean,
double  var 
)

Generates a random double within a given range.

Returns a randomly generated double in a gamma distribution between a given min and max.

Parameters
mindouble
maxdouble
Returns
double
void Physics::resolveCollision ( Particle lP,
Particle rP,
int  timestep 
)

Resolves a collision between two Particles.

Resolves a collision between pointers to two given Particles at a given timestep.

Parameters
lPpointer to the first Particle.
rPpointer to the second Particle.
timestepint
virtual void Physics::updatePositionAndVelocity ( Particle p,
int  timestep 
)
pure virtual

Updates the position and velocity of a Particle.

Updates the position and velocity of a given Particle at a given timestep. Each Algorithm implements it's own version.

Parameters
ppointer to the Particle to be updated.
timestepint

The documentation for this class was generated from the following files: