I have been trying to make a physics class for to test on an gui, but when I get the output, it's not a # persay. I'm not even sure if the physics are right, and I will be looking into it, but I'm posting here to find out why i didn't get a #. If you see any problems with the physics part of it that would be greatly appreciated too.
Here is my code
and my output is:Code:#include <iostream> #include <vector> using namespace std; vector <float> force; class physics { public: physics(double x, double y, double h, double w, double top_speed, double density, double friction_level); void apply_force(vector <float> force); private: vector <double> main_vector; }; physics::physics(double x, double y, double h, double w, double top_speed, double density, double friction_level) { //set up main vector main_vector.push_back(x); main_vector.push_back(y); main_vector.push_back(h); main_vector.push_back(w); main_vector.push_back(top_speed); main_vector.push_back(density); main_vector.push_back(friction_level); // find volume and mass // first we will find volume = h * w main_vector.push_back(main_vector[2] * main_vector[3]); // now lets find mass = V * D main_vector.push_back(main_vector[6] * main_vector[8]); // now we are going to find the gravity of the object using force = mass * 9.8(earth grav) main_vector.push_back(main_vector[9] * 9.8); // find friction main_vector.push_back(main_vector[6] * main_vector[10]); //lets make some room to put acceleration in there! remember we need one for x and y main_vector.push_back(0); main_vector.push_back(0); } void physics::apply_force(vector <float> force) { // acceleration = force/ mass * for both x and y // also not we subtract friction from it if(force[0]/main_vector[8] > 0) { main_vector[12] = (force[0] - main_vector[11] )/main_vector[8] ; } if(force[0]/main_vector[8] <= 0) { main_vector[12] = (force[0] - main_vector[11]) /main_vector[8] ; } if(force[1]/main_vector[8] > 0) { main_vector[13] = (force[1] - main_vector[11]) /main_vector[8]; } if(force[1]/main_vector[8] <= 0) { main_vector[13] = (force[1] - main_vector[11]) /main_vector[8]; } main_vector[0] += main_vector[12]; main_vector[1] += main_vector[13]; cout<< main_vector[0] << ", " << main_vector[1] << "\n"; } int main() { force.push_back(10); force.push_back(30); physics car(5, 5, 25, 25, 20, 40, 0.5); car.apply_force(force); return 0; }
1.#INF, 1.#INF
Thanks for any help,
Joe



LinkBack URL
About LinkBacks


