Skip to content

Commit

Permalink
Merge branch 'floor-shot-physics' of https://github.com/team581/offse…
Browse files Browse the repository at this point in the history
…ason-2024-gamma into floor-shot-physics
  • Loading branch information
Owen756 committed May 15, 2024
2 parents 97c1d3d + 41553a1 commit 6636243
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/main/python/modeling/shooter_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import dataclasses
import math

import numpy as np
import matplotlib.pyplot as plt

@dataclasses.dataclass
class VelocityVector():
angle: float # Degrees
velocity: float # Meters / Sec

@dataclasses.dataclass
class NotePosition():
x: float # Meters
y: float # Meters

class ShooterModel:

def __init__(self, timestep_seconds: int):
self.timestep_seconds = timestep_seconds


def graph_note(self, note_exit_vector: VelocityVector):
print(note_exit_vector.angle)
print(note_exit_vector.velocity)

note_position = []
for t in range(100):
position = NotePosition((t*(note_exit_vector.velocity * math.cos(note_exit_vector.angle * (math.pi/180)))) + 5,
(-(1/2)*9.8*math.pow(t,2)) + (t*(note_exit_vector.velocity * math.sin(note_exit_vector.angle * (math.pi/180)))) + 5)
note_position.append((t, position))

if position.y <= 0:
break


figure, axis = plt.subplots()
axis.plot(np.array([pos[1].x for pos in note_position]),
np.array([pos[1].y for pos in note_position]))

axis.set(xlabel="X Postion",
ylabel="Y Position",
title="Title")
axis.grid()

plt.show()



robot_shooter = ShooterModel(0.02)

robot_shooter.graph_note(VelocityVector(60, 100))

0 comments on commit 6636243

Please sign in to comment.