Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Tue Oct 15 13:47:44 2019
- @author: nvanderkroon
- """
- import matplotlib.pyplot as plt
- import numpy as np
- f = 1.5 #N
- m = 2 #kg
- a_haas = f/m
- v_0 = 1.3 #ms^-1
- a_schildpad = -0.1 #ms^-2
- s_0 = 15 #m
- t = np.linspace(0, 10, 1000)
- def shaas(a, t):
- return 0.5*a*t**2
- def sschildpad(s0, v0, a, t):
- return s0+(v0+a*0.5*t)*t
- def verschil(sh, ss):
- return sh - ss
- s_haas = shaas(a_haas, t)
- s_schildpad = sschildpad(s_0, v_0, a_schildpad, t)
- vschl = verschil(s_haas, s_schildpad)
- #index = np.argwhere(np.diff(np.sign(s_haas - s_schildpad)))
- def getindex(haas, schildpad):
- for i in range(len(haas)):
- if haas[i] >= schildpad[i]:
- return i
- index = getindex(s_haas, s_schildpad)
- plt.plot(t, s_haas) #plot van haas
- plt.plot(t, s_schildpad)
- plt.plot(t[index], s_schildpad[index], 'rx')
- tijd = np.round(float(t[index]), 3)
- 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