Description
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.
Try run the code.
Read and understand the codes.
This code solves the projectile of an object within frictionless fluid.
The governing equation is:
where m is the weight, and is the gravitational acceleration, which is:
and .
4/23/2018 Homework 11
https://tulane.instructure.com/courses/2165899/assignments/13472564 2/3
Compung 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:
The acceleration is simply
Compung the posion coordinate
Since
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:
Analycal Soluon
The governing equation can be solved analytically.
where is the initial velocity.
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:
where m is the weight, 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.
4/23/2018 Homework 11
https://tulane.instructure.com/courses/2165899/assignments/13472564 3/3
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.