File size: 1,052 Bytes
5ecfb7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import math
import gradio as gr

def compute_projectile_distance(initial_speed, angle):
    """
    Calculate the horizontal distance traveled by a projectile.

    Parameters:
    initial_speed (float): Initial speed of the projectile in m/s
    angle (float): Launch angle in degrees

    Returns:
    float: Horizontal distance traveled in meters
    """
    # Convert angle from degrees to radians
    angle_rad = math.radians(angle)

    # Gravitational acceleration (m/s²)
    g = 9.81

    # Calculate the horizontal distance using the projectile motion formula:
    # distance = (initial_speed² * sin(2*angle)) / g
    distance = (initial_speed**2 * math.sin(2 * angle_rad)) / g
    return distance

app = gr.Interface(
    fn=compute_projectile_distance,
    inputs=["number", "number"],
    outputs="number",
    title="Compute Projectile Distance",
    description="Computes the theoretical horizontal distance a projectile travels for a given initial speed and angle."
)

#Initialiser l'application
app.launch(mcp_server=True, share=True)