Question: plClass initialisationease use python a ) Class initialisation Set up a class Projectile which takes in an angle in degrees, velocity and height at launch

plClass initialisationease use python
a)Class initialisation
Set up a class Projectile which takes in an angle in degrees, velocity and height at launch and converts this data to class attributes xpos, ypos, xvel and yvel. If you need any further information, define it appropriately.
b) Returning information about the class
Add two helper functions to your class. One to return the x position of the projectile, the other to return the y position.
c) Introducing the dynamics
Now add a method to your class which steps forward by \Delta t. Use a simple Euler forward step in this update function. The equations of motion in the x and y directions are:
d2xdt2=0,d2y/dt2=-g,
where g=9.8ms2. Call your function update and have it accept a single parameter t.
Amendment Some further information may be helpful here. The speed of a projectile in the x direction is given by dxdt(let's call it v), while the speed in the y direction is given by dydt(let's call it w). To 'solve' this problem over one time step, we need to carry out the following steps:
Write the equations as a system of first-order ODEs
Represent each ODE in finite difference form, e.g.dxdt=v becomes
xn+1=xn+tvn
where x and v are two dependent variables
Start the map off by specifying the initial conditions, i.e.(x0,v0,y0,w0). You are asked to write a method which steps these dependent variables forward by one step t.
d) Solving a problem with the class
With an initial angle of 30 degrees, an initial speed of 10ms and a height of 2 metres, how far has the projectile travelled (in the x direction) when it hits the
ground

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!