Coder Social home page Coder Social logo

hw_projectiles's Introduction

hw_projectiles

Homework for Garcia Ch. 2, projectile motion

Contents

GUI Tutorial (in class)

Follow the GUI tutorial to create a 4-function calculator GUI! Add your calculator GUI files to github.

Problem 1 (in class)

Complete the function in projectiles.m to compute the trajectory of a projectile under the influence of gravity alone using the Euler, Euler-Cromer, and Midpoint methods. Using the initial conditions that are provided as inputs and computed already, implement a time step loop that updates the position and velocity of the projectile.

  • Calculate the position analytically to compare to your numerical method
  • Calculate Euler, Euler-Cromer, and Midpoint method updates for position and velocity at each time step, depending on which method was given as a function argument.
  • Store horizontal and vertical positions for plotting
  • Break the time step loop when the particle hits the ground
  • Plot the trajectory of the projectile (y vs x position) for the analytical solution and the chosen numerical solution on the same graph in different styles.

Test the code for the initial conditions and parameters of Garcia Figure 2.2 (x0 = y0 = 0, v0 = 15 m/s, θ0=45°, τ = 0.1 s, no drag). The final function input parameter can be used to control the numerical method; such as 1 = Euler, 2 = Euler-Cromer, 3 = Midpoint.

Execute this command in the Command Window to test using Method 1 (whatever that is for you):

>> projectiles(0, 15, 45, 0, 0.1, 1)

Problem 2 (homework)

Wrap your program in a GUI! The GUI can be as creative as you'd like, but should prompt the user to enter initial conditions and choose a calculation method. A basic functional GUI is shown below.

  • Test the code for the different methods using the same initial conditions and parameters.
  • What conclusions can be drawn about the performance of the different methods? Write your answer in a commented paragraph at the end of projectiles.m.

Problem 3 (homework)

Add the option to include an air resistance force on the projectile. This term will modify the net force (and acceleration) on the projectile. Thus, the net force on the projectile becomes:

Here, ρ = density of air = 1.2 kg/m3, Cd = drag coefficient = 0.35 for a baseball, A = cross-sectional area of the projectile (R = 0.037 m for a baseball), and m = projectile mass = 0.145 kg for a baseball.

Test your program for the launch of a baseball with the following initial conditions (x0 = y0 = 0, v0 = 55 m/s, θ0 = 45°, τ = 0.1 s).

Display your results as a figure with two subplots: one subplot displays the projectile trajectory (x vs. y); the other subplot displays the projectile velocity magnitude versus time.

Problem 4 (homework)

The drag coefficient for a baseball actually varies with velocity. Modify your program to account for a drag coefficient that varies with velocity according to the table shown. Use linear interpolation to determine the drag coefficient for speeds between values in the table. Test your conditions for the same initial conditions and parameters as in Problem #1.

Display your results as a figure with two subplots: one subplot displays the projectile trajectory (x vs. y); the other subplot displays the projectile velocity magnitude versus time.

v (m/s) Cd
0 0.5
11 0.5
22 0.5
33 0.4
44 0.28
55 0.23
55+ 0.23

hw_projectiles's People

Contributors

jmhogan avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.