From 45d36611b3a962a8af36f22864a88702999fb0be Mon Sep 17 00:00:00 2001 From: Ritwik Gupta Date: Wed, 24 Dec 2014 15:40:23 -0500 Subject: [PATCH 1/4] Added solar system field --- Planet.cc | 4 +++- Planet.h | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Planet.cc b/Planet.cc index 471130e..9b0208a 100644 --- a/Planet.cc +++ b/Planet.cc @@ -4,7 +4,7 @@ #include #import "Planet.h" -Planet::Planet(int mass, int radius, Point origin, Vector heading): mass(mass), radius(radius), origin(origin), heading(heading) +Planet::Planet(int mass, int radius, int solar_system, Point origin, Vector heading): mass(mass), radius(radius), solar_system(solar_system), origin(origin), heading(heading) { } @@ -14,12 +14,14 @@ std::string Planet::toString() x << "Mass: " << mass << "\n" << "Radius: " << radius << "\n" + << "Solar System: " << solar_system << "\n" << "Position: " << origin.toString() << "\n" << "Heading: " << heading.toString() << "\n"; return x.str(); } + // Calculates the gravitational pull from this planet to a given planet P double Planet::calculateGravity(Planet &p) { diff --git a/Planet.h b/Planet.h index 59485e5..c51e3d7 100644 --- a/Planet.h +++ b/Planet.h @@ -10,13 +10,14 @@ class Planet public: int mass; int radius; + int solar_system; Point origin; Vector heading; std::string toString(); - Planet(int mass, int radius, Point position, Vector heading); + Planet(int mass, int radius, int solar_system, Point position, Vector heading); void distance(Planet &p, double &horizontalDistance, double &verticalDistance); double calculateGravity(Planet &p); Vector findVector(Planet &p); From 2d8a815d8140d3c714792056e1bd1df176b6b71f Mon Sep 17 00:00:00 2001 From: Ritwik Gupta Date: Thu, 25 Dec 2014 14:04:04 -0500 Subject: [PATCH 2/4] Added constants --- Constants.cc | 15 +++++++++++++++ Constants.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 Constants.cc create mode 100644 Constants.h diff --git a/Constants.cc b/Constants.cc new file mode 100644 index 0000000..87b028c --- /dev/null +++ b/Constants.cc @@ -0,0 +1,15 @@ +#include "Constants.h" + +const double Constants::Pi = 3.14159265358979323846264; +const double Constants::c = 2.99792458e+8; +const double Constants::Tesla_to_inner = (1.0e+4/4.8032068e-10)*0.01*(1.0e+6); +const double Constants::VoltsPerM_to_inner = 1.0/((1.6021773e-19)*(8.98755179e+9)); +const double Constants::permeability = 4*3.14159265358979323846264*1.0e-007; +const double Constants::electron_mass = 0.510998910e-3; +const double Constants::electron_charge = -1.0; +const double Constants::proton_mass = 0.938272013; +const double Constants::proton_charge = +1.0; + +Constants::Constants(){} + +Constants::~Constants(){} diff --git a/Constants.h b/Constants.h new file mode 100644 index 0000000..d90fc56 --- /dev/null +++ b/Constants.h @@ -0,0 +1,38 @@ +#ifndef CONSTANTS_ORBIT +#define CONSTANTS_ORBIT + +class Constants { +public: + Constants(); + ~Constants(); + + //Pi + const static double PI; + + //Speed of light in m/sec + const static double c; + + //Magnetic field strength + //To convert from Tesla to H/e in 1/m^2 + const static double Tesla_to_inner; + + //Convert from Volts/m to E in 1/m^2 + const static double VoltsPerM_to_inner; + + //Magnetic permeability + const static double permeability; + + //Electron mass in GeV + const static double electron_mass; + + //Charge of electron + const static double electron_charge; + + //Proton mass in GeV + const static double proton_mass; + + //Charge of proton + const static double proton_charge; +} + +#endif From ba11c57e2b487444afad704e48ff36fc14d53668 Mon Sep 17 00:00:00 2001 From: Ritwik Gupta Date: Thu, 25 Dec 2014 14:27:59 -0500 Subject: [PATCH 3/4] Removed useless constants --- Constants.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Constants.cc b/Constants.cc index 87b028c..f5606ca 100644 --- a/Constants.cc +++ b/Constants.cc @@ -2,13 +2,9 @@ const double Constants::Pi = 3.14159265358979323846264; const double Constants::c = 2.99792458e+8; -const double Constants::Tesla_to_inner = (1.0e+4/4.8032068e-10)*0.01*(1.0e+6); -const double Constants::VoltsPerM_to_inner = 1.0/((1.6021773e-19)*(8.98755179e+9)); const double Constants::permeability = 4*3.14159265358979323846264*1.0e-007; const double Constants::electron_mass = 0.510998910e-3; -const double Constants::electron_charge = -1.0; const double Constants::proton_mass = 0.938272013; -const double Constants::proton_charge = +1.0; Constants::Constants(){} From d9bd7085d5c3ce60f3e586296a507cfe84624521 Mon Sep 17 00:00:00 2001 From: Ritwik Gupta Date: Thu, 25 Dec 2014 14:54:56 -0500 Subject: [PATCH 4/4] Removed constants from header --- Constants.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Constants.h b/Constants.h index d90fc56..1915670 100644 --- a/Constants.h +++ b/Constants.h @@ -12,27 +12,14 @@ class Constants { //Speed of light in m/sec const static double c; - //Magnetic field strength - //To convert from Tesla to H/e in 1/m^2 - const static double Tesla_to_inner; - - //Convert from Volts/m to E in 1/m^2 - const static double VoltsPerM_to_inner; - //Magnetic permeability const static double permeability; //Electron mass in GeV const static double electron_mass; - //Charge of electron - const static double electron_charge; - //Proton mass in GeV const static double proton_mass; - - //Charge of proton - const static double proton_charge; } #endif