# Define the initial parameters of the projectile angle = 45.0 # Launch angle in degrees velocity = 30.0 # Launch velocity in meters per second gravity = 9.81 # Acceleration due to gravity in meters per second squared # Convert the launch angle to radians angle_radians = angle * 3.14159 / 180.0 # Calculate the initial components of the velocity vx = velocity * cos(angle_radians) vy = velocity * sin(angle_radians) # Define the initial position of the projectile x = 0.0 # Initial horizontal position in meters y = 0.0 # Initial vertical position in meters # Define the time step and total simulation time dt = 0.01 # Time step in seconds t_max = 10.0 # Total simulation time in seconds # Define lists to store the x and y positions of the projectile at each time step x_values = [] y_values = [] # Use a while loop to calculate the position of the projectile at each time step t = 0.0 # Initial time while y >= 0.0 and t <= t_max { # Calculate the x and y components of the acceleration ax = 0.0 # No horizontal acceleration ay = -gravity # Vertical acceleration due to gravity # Use the x and y components of the acceleration to update the x and y components of the velocity vx += ax * dt vy += ay * dt # Use the x and y components of the velocity to update the x and y positions of the projectile x += vx * dt y += vy * dt # Append the current x and y positions to the x_values and y_values lists x_values.append(x) y_values.append(y) # Increment the time by the time step t += dt } # Print the final x and y positions of the projectile print("Final position: ({:.2f}, {:.2f})".format(x, y)) # Plot the trajectory of the projectile using the H scripting language's built-in plot function plot(x_values, y_values, "Projectile Trajectory")