projectile-sim 1.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
projectile/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from .projectile_sim import Projectile
@@ -0,0 +1,51 @@
1
+ # OOP projectile motion
2
+ import math
3
+ import numpy as np
4
+ import matplotlib.pyplot as plt
5
+
6
+ class Particle(object):
7
+ def __init__(self):
8
+ self.position = [0.0, 0.0]
9
+
10
+ class Projectile(Particle):
11
+ def __init__(self, velocity, angle, initial_height, dt):
12
+ super().__init__()
13
+ self.velocity = velocity
14
+ self.angle = angle
15
+ self.initial_height = initial_height
16
+ self.position = [0.0, initial_height]
17
+ self.time = 0.0
18
+ self.dt = dt
19
+ self.g = -9.81
20
+
21
+ def update_position(self, dt):
22
+ self.time += dt
23
+ self.position[0] = self.velocity * math.cos(math.radians(self.angle)) * self.time
24
+ self.position[1] = self.initial_height + (self.velocity * math.sin(math.radians(self.angle)) * self.time) + (0.5 * self.g * self.time ** 2)
25
+
26
+ def get_position(self):
27
+ return tuple(self.position)
28
+
29
+ def get_time(self):
30
+ return self.time
31
+
32
+ def get_max_height(self):
33
+ return self.initial_height + (self.velocity ** 2 * (math.sin(math.radians(self.angle))) ** 2) / (2 * -self.g)
34
+
35
+ if __name__ == "__main__":
36
+ ball = Projectile(velocity=10.0, angle=45.0, initial_height=10.0, dt=0.01)
37
+ print(f"Initial x, y: {ball.get_position()} (m)")
38
+
39
+ x_positions = [ball.get_position()[0]]
40
+ y_positions = [ball.get_position()[1]]
41
+
42
+ while ball.position[1] >= 0:
43
+ ball.update_position(ball.dt)
44
+ x_positions.append(ball.get_position()[0])
45
+ y_positions.append(ball.get_position()[1])
46
+
47
+ print(f"Final x, y: ...")
48
+
49
+ fig, ax = plt.subplots(figsize=(8, 5)) # <-- moves in here
50
+ ax.plot(x_positions, y_positions)
51
+ plt.show()
@@ -0,0 +1,4 @@
1
+ Metadata-Version: 2.4
2
+ Name: projectile-sim
3
+ Version: 1.1.0
4
+ Requires-Dist: numpy
@@ -0,0 +1,6 @@
1
+ projectile/__init__.py,sha256=JHUd_k73n8QfCNUketgslManoyL7qYowFY17zlhVCas,38
2
+ projectile/projectile_sim.py,sha256=85OLEjUZHMGDgNv9VQZ9mnKyiNhUE6N1CMj6hbSFsQY,1648
3
+ projectile_sim-1.1.0.dist-info/METADATA,sha256=PJy4BpD93uo0MIuJIpv8xb9lN-3PRzyfuwYHXhZuAEw,79
4
+ projectile_sim-1.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
5
+ projectile_sim-1.1.0.dist-info/top_level.txt,sha256=mmPLBji039FFGl0RgD1KKeol8zWFUbIN7z7D7uEgB4w,11
6
+ projectile_sim-1.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ projectile