Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Constants.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "Constants.h"

const double Constants::Pi = 3.14159265358979323846264;
const double Constants::c = 2.99792458e+8;
const double Constants::permeability = 4*3.14159265358979323846264*1.0e-007;
const double Constants::electron_mass = 0.510998910e-3;
const double Constants::proton_mass = 0.938272013;

Constants::Constants(){}

Constants::~Constants(){}
25 changes: 25 additions & 0 deletions Constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#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 permeability
const static double permeability;

//Electron mass in GeV
const static double electron_mass;

//Proton mass in GeV
const static double proton_mass;
}

#endif
4 changes: 3 additions & 1 deletion Planet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <iostream>
#include "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)
{
}

Expand All @@ -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)
{
Expand Down
3 changes: 2 additions & 1 deletion Planet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down