def find_slope(shot_vector: Vector3, car_to_target: Vector3) -> float: # Finds the slope of your car's position relative to the shot vector (shot vector is y axis) # 10 = you are on the axis and the ball is between you and the direction to shoot in # -10 = you are on the wrong side # 1.0 = you're about 45 degrees offcenter d = shot_vector.dot(car_to_target) e = abs(shot_vector.cross((0, 0, 1)).dot(car_to_target)) return cap(d / e if e != 0 else 10 * sign(d), -3.0, 3.0)
def find_slope(shot_vector: Vector3, car_to_target: Vector3) -> float: # Finds the slope of your car's position relative to the shot vector (shot vector is y axis) # 10 = you are on the axis and the ball is between you and the direction to shoot in # -10 = you are on the wrong side # 1 = you're about 45 degrees offcenter d = shot_vector.dot(car_to_target) e = abs(shot_vector.cross(Vector3(0, 0, 1)).dot(car_to_target)) try: f = d / e except ZeroDivisionError: return 10 * sign(d) return cap(f, -3, 3)