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
aClass 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:
yd
where Call your function update and have it accept a single parameter
Amendment Some further information may be helpful here. The speed of a projectile in the direction is given by lets call it while the speed in the direction is given by lets call it To 'solve' this problem over one time step, we need to carry out the following steps:
Write the equations as a system of firstorder ODEs
Represent each ODE in finite difference form, eg becomes
where and are two dependent variables
Start the map off by specifying the initial conditions, ie You are asked to write a method which steps these dependent variables forward by one step
d Solving a problem with the class
With an initial angle of degrees, an initial speed of and a height of metres, how far has the projectile travelled in the direction when it hits the
ground
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
