I am trying to make a program to simulate movement. This is the code
class Object:
forc={}
srtpos = 0
vel = 0
def __init__(self,mass, srtpos = 0):
self.mass = mass
self.srtpos = 0
def UpVel(vel, time = 1, a = 0):
vel1 = vel + a*t
vel = vel1
def Move(self, vel, time = 1, a = 0):
self.srtpos+= self.vel*time +(0.5)*a*(time**2)
UpVel(self.vel, time, a)
a = Object(5)
print(a.srtpos)
for i in range(5):
a.Move(5)
print(a.srtpos)
The UpVel()
function is updating the velocity. When i try to run this through the Move()
function, the program is giving me error
Traceback (most recent call last):
File "/media/atharva/DATA/Python/PhySim.py", line 17, in <module>
a.Move(5)
File "/media/atharva/DATA/Python/PhySim.py", line 13, in Move
UpVel(self.vel, time, a)
NameError: name 'UpVel' is not defined
I have tried putting the function call in __main__
and also changing the name of the function.
Any help appreciated. Thanks in advance.