|
|
|
def predict_impact(ball_positions: list) -> tuple: |
|
""" |
|
Predict the ball's impact point on the stumps or pad based on trajectory. |
|
Returns (x, y) coordinates of the predicted impact point. |
|
""" |
|
if not ball_positions or len(ball_positions) < 2: |
|
return None |
|
|
|
x1, y1 = ball_positions[-2] |
|
x2, y2 = ball_positions[-1] |
|
|
|
stump_y = 600 |
|
if y2 == y1: |
|
return None |
|
|
|
slope = (x2 - x1) / (y2 - y1) |
|
impact_x = x1 + slope * (stump_y - y1) |
|
|
|
return (impact_x, stump_y) |
|
|
|
def is_drs_out(impact_point: tuple) -> bool: |
|
""" |
|
Determine if the ball meets DRS criteria for an Out decision. |
|
Returns True (Out) or False (Not Out). |
|
""" |
|
if impact_point is None: |
|
return False |
|
|
|
x, y = impact_point |
|
stump_x_min, stump_x_max = 400, 800 |
|
|
|
return stump_x_min <= x <= stump_x_max |