viswanani's picture
Update bounce.py
2fa5e6c verified
raw
history blame contribute delete
246 Bytes
import numpy as np
def detect_bounce(trajectory):
ys = [y for _, y in trajectory]
dy = np.diff(ys)
bounce_index = np.argmax(dy > 15) if np.any(dy > 15) else None
return int(bounce_index) if bounce_index is not None else None