Spaces:
Build error
Build error
File size: 510 Bytes
de182d4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import numpy as np
from scipy.optimize import curve_fit
def predict_trajectory(points):
if len(points) < 5:
raise ValueError("Not enough data points for trajectory prediction.")
points = np.array(points)
x = points[:, 0]
y = points[:, 1]
def poly2(x, a, b, c):
return a * x**2 + b * x + c
try:
params, _ = curve_fit(poly2, x, y)
except Exception as e:
print(f"Curve fitting failed: {e}")
raise e
return params
|