lohajackson.blogg.se

Projectile motion calculator
Projectile motion calculator














ProjectileMotion should be ProjectileMotion by PEP8.ĭon't alias math as m math should be fine for your purposes.

#PROJECTILE MOTION CALCULATOR FREE#

But you can still comment on that )Īs a beginner, any genuine advice is a blessing, so please feel free to share all your thoughts. Note: a run() method will most likely be added instead of running everything in the initialization. """Could then be processed to make graphs and whatnot"""įor line in speed_y0_distance_best_angle: print(line) Speed_y0_distance_best_angle.append(find_best_angle(speed, y0)) Return (speed, y0, round(max_distance,1), best_angle) from projectile_oop_v2 import projectileMotionįind the angle at which the thow goes the farthestĭistance = projectileMotion(angle=angle, velocity=speed, y_init=y0).dx I include it as well since you could have things to say about the way I do things.

projectile motion calculator

Now, this is a second file I used to try doing things with the class. Obj = projectileMotion(velocity=10, angle=30, y_init=5)įor k, val in obj._dict_.items(): print(k, val, "\n\n") Return list(zip(self.dx_vect, self.dy_vect)) Y = self.y_init + self.vy_init*max_y_t - self.g/2 * max_y_t**2 Max_y atteined when vy - g*t = 0 (when the velocity induced by gravity = vy) Return dt, ĭx_vect = ĭy_vect = ĭy = dy_vect - self.y_init T_total = (vy + sqrt(vy**2 + 2*y0*g)) / gĭt_vect contains the time at n_steps, the first one being 0ĭt = (self.vy_init + m.sqrt(self.vy_init**2 + 2*self.y_init*self.g))/self.g T_total = time taken for the object to fall on the ground (y=0) Return self.velocity_init * m.sin(m.radians(self.angle_init)) Return self.velocity_init * m.cos(m.radians(self.angle_init)) Self.dy, self.dy_vect = self.calc_dy_and_vect() Self.dx, self.dx_vect = self.calc_dx_and_vect() Self.dt, self.dt_vect = self.calc_dt_and_vect() Self.vy_init = self.calc_vy_init() #into two normal velocity vectors. Self.vx_init = self.calc_vx_init() #Turn the angled velocity vector Between 30 and 50 for more accuracyĭef _init_(self, velocity, angle, y_init=0): N_steps = 5 #small here for testing purpose. The friction forces are neglected, thus the only formula used is theįollowing: # △X = x0 + v_x⋅△t - a_x/2⋅△t^2 (and some of its variations)

projectile motion calculator

Is 0 by default but can be set by the user when creating an instance. This class calculate the movement of a projectile using its initial velocityĪnd the angle at witch it is thrown/shot. I explain more what I actually do in the code's comments, and I tried to be quite explanatory with names etc. I'd like to hear your constructive criticisms about my first OOP project.














Projectile motion calculator