Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Tue Oct 15 13:47:44 2019
  4.  
  5. @author: nvanderkroon
  6. """
  7.  
  8. import matplotlib.pyplot as plt
  9. import numpy as np
  10.  
  11. f = 1.5 #N
  12. m = 2 #kg
  13. a_haas = f/m
  14. v_0 = 1.3 #ms^-1
  15. a_schildpad = -0.1 #ms^-2
  16. s_0 = 15 #m
  17.  
  18. t = np.linspace(0, 10, 1000)
  19.  
  20. def shaas(a, t):
  21. return 0.5*a*t**2
  22.  
  23. def sschildpad(s0, v0, a, t):
  24. return s0+(v0+a*0.5*t)*t
  25.  
  26. def verschil(sh, ss):
  27. return sh - ss
  28.  
  29. s_haas = shaas(a_haas, t)
  30. s_schildpad = sschildpad(s_0, v_0, a_schildpad, t)
  31. vschl = verschil(s_haas, s_schildpad)
  32.  
  33. #index = np.argwhere(np.diff(np.sign(s_haas - s_schildpad)))
  34.  
  35. def getindex(haas, schildpad):
  36. for i in range(len(haas)):
  37. if haas[i] >= schildpad[i]:
  38. return i
  39.  
  40.  
  41.  
  42. index = getindex(s_haas, s_schildpad)
  43.  
  44. plt.plot(t, s_haas) #plot van haas
  45. plt.plot(t, s_schildpad)
  46.  
  47. plt.plot(t[index], s_schildpad[index], 'rx')
  48.  
  49. tijd = np.round(float(t[index]), 3)
  50.  
  51. print('De haas kruist de schildpad op t = ', tijd, 'seconden en haalt hem hierna dus in')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement