File size: 1,268 Bytes
446bb6d
 
7426fb3
5535e63
7426fb3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207494f
 
7426fb3
 
 
 
 
 
 
b7a93fc
7426fb3
 
151cd1b
f2fd206
 
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
36
37
38
39
40
# Credit to original author https://ai.gopubby.com/build-mcp-servers-and-host-them-for-free-a54a3bd24513

import gradio as gr
import math

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
    print("Distance of the projectile: ", distance)
    return distance


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


#app.launch(mcp_server=True, share=True)
app.launch(server_name="0.0.0.0", server_port=7860, ssl_verify=False)