I'm working on a project to create a new "class" in python to do some kinematics calculations.
But, I'm having trouble seeing how to build the formula in python given the common physics kinematics equations.
Here is the general goal:
"Construct a class named projectile. The class variable should include the height from which the projectile is shot, the height at which it lands, the initial velocity, and the angle of the initial velocity with respect to the horizontal. The class methods should include a calculation of the range of the projectile, its maximum height and its final velocity."
I got as far as defining the new class and the variables, but am not sure how to build the functions. Any assistance would be so helpful. Here is the code so far:
import math
import numpy as np
import matplotlib.pyplot as plt
import pylab
import os
# acceleration due to gravity = 9.80665 m/s**2
class Projectile(object):
# h0 is vertical starting position which starts at y = 0
def __init__(self,h0,v0,theta):
self.h0 = h0 #height
self.v0 = v0 #speed
self.theta = theta # angle above horizontal
self.v0x = v0*math.cos(theta) #x component of velocity
self.v0y = v0*math.sin(theta) #y component of velocity