COSC6000 Homework 12

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (6 votes)

In HW11, we have developed “ProjectileWithDrag” class. Following code tests the class and exports results from both ‘Projectile’ and ‘ProjectileWithDrag’ to files. #include #include #include #include #include #include #include “Projectile.h” #include “ProjectileWithDrag.hpp” using namespace cosc3000; void simulation(Projectile *obj, std::ostream &strm,double dt){ while(1){ /// data out strm << *obj << std::endl; /// increment time obj->update(dt); /// check if it hit ground vector2d cord = obj->get_coordinate(); if (cord.get_y() < 0.0) break; } } int main(int argc, const char * argv[]) { // initial conditions const double init_speed=10.0; const double init_angle=M_PI_4; // PI/4 const double weight1 = 1.0; const double dt = 0.01; // Create objects std::vector objects; objects.push_back(new Projectile(weight1,init_speed,init_angle)); objects.push_back(new ProjectileWithDrag(weight1,init_speed,init_angle,0.1)); /// compute numerical solution std::ofstream file; for (int i = 0 ; i < objects.size() ; i++){ std::stringstream fileName; fileName << “Trajectory” << std::setfill(‘0’) << std::setw(2) << i << “.txt”; 4/24/2018 Homework 12 https://tulane.instructure.com/courses/2165899/assignments/13474160 2/3 file.open(fileName.str()); simulation(objects[i],file,dt); file.close(); } return 0; }  But, the results were not what expected. It should be: 4/24/2018 Homework 12 https://tulane.instructure.com/courses/2165899/assignments/13474160 3/3 How do we fix the problem? You cannot change ‘main’ and ‘simulation’ functions. You may change the order of input parameter and/or namespace for “ProjectileWithDrag” class according to your definition. Upload all files you need to compile the code.