need help plotting coordinates of position vector array within loop

Viewed 17

im trying to plot the x and y coordinate of the r-vector in a loop, but don't get how to call the coordinates to iterate in loop. If i could get some help that would be great.

import numpy as np
import math as m
import matplotlib as plt

g = np.array([0,-9.8,0])

r = np.array([0,1.2,0])

theta = 35 * m.pi / 180

v1 = 3.3

v = v1 * np.array([np.cos(theta),np.sin(theta),0])

a = g

t = 0

dt = .01

while r[1]  > 0:
    v = v + a * dt
    r = r + v * dt
    t = t + dt
    plt.plot(r)
    
print("r = ",r , "m")

print("t = ",t, "s")

print("v = ",v, "m/s")
0 Answers
Related