Hey I'm a fairly new to this so take it easy please.
I've written a very simple program to simple print the gravitational force between two objects but I am not getting a value returned (or i am getting an immeasurably small value).
Actually, come to think of it, I think 9.81 might be the Earth's gravitational constant, which wouldn't be used for the gravitational force between two objects.
Use this instead, the standard gravitational constant. The number is a little crazy, so just define the calc as the constant...
constdouble GRAVITY = 6.67428 * pow( 10.0, -11 );
You'll need to #include <cmath> for that to work.
This assumes your mass is measured in kg and your distance in metres. Your gravitational force will be measured in Newtons.
#include <iostream>
#include <conio.h>
#include <math.h>
void calc (void);
usingnamespace std;
constdouble GRAVITY = 6.67428 * pow( 10.0, -11 );
double FG;
int m1= 1;
int m2= 1;
int distance;
int main ()
{
cout << "Please enter the mass of object one (KG)\n";
cin >> m1;
cout << "Please enter the mass of object two (KG)\n";
cin >> m2;
calc();
}
void calc (void)
{
double FG;
int distance=4;
FG=GRAVITY*(m1*m2)/(distance*distance);
cout << "The gravotinal force in netwons is "<< FG;
getch();
}
I'm eager to make something I can visualize. If I draw an x,y axis how hard would it be to draw some dots to represent different objects and see the effects of them pulling together. I'm not sure where one would start.