$35
Download
ProjectileMain.cpp
Projectile.h Projectile.cpp vector2d.h vector2d.cpp from Canvas site: Link
Create a project on your IDE (Xcode, Visual Studio)
For Visual Studio, it may be better to create, 'vector2d' and 'Projectile' class and copy and paste the codes.
This code solves the projectile of an object within frictionless fluid.
The governing equation is:
is the gravitational acceleration, which is:
Compu ng the velocity Since
the finite difference form of above equation (first order Euler method) is Therefore the update scheme for the velocity with in a time step, is:
Compu ng the posi on coordinate
the finite difference form of above equation (first order Euler method) is
Therefore the update scheme for the position coordinate with in a time step, is:
Analy cal Solu on
The governing equation can be solved analytically. where
Assignment
We want to develop a code to simulate the projectile of a ball/bullet in a viscous fluid. The trajectory of the ball/bullet can be described by three components; the coordinate , the velocity and the acceleration
.
The governing equation is:
is the gravitational acceleration, D is a drag coefficient.
Develop the class “ProjectileWithDrag” that will provide a method to compute the trajectory of an object in a viscous fluid with a nonlinear drag.
Define the class “ProjectileWithDrag” derived from “Projectile” class.
a constructor that takes the bullet weight, the bullet initial speed , the angle, and the drag coefficient, D.
set the initial velocity using the initial speed and the angle.
set the initial coordinate to (0,0), acceleration to (0,g), and the time to 0. a default constructor (takes no input) that initialize all member variable to zero. Redefine update(double dt) that updates the coordinate, velocity and acceleration as
Modify the main function to test your class.
Try making a plot of your result and compare with the dragfree case.