Vous êtes sur la page 1sur 2

import numpy as np

import matplotlib.pyplot as plt


from mpl_toolkits.mplot3d import Axes3D
# Dimensions d'un terrain de tennis standard (en mètres)
terrain_longueur = 23.77
terrain_largeur = 8.23
filet_hauteur = 0.5
# Paramètres
g = 9.81 # Accélération due à la gravité (m/s^2)
dt = 0.01 # Intervalle de temps (s)
v0 = 10.0 # Vitesse initiale (m/s)
theta = np.pi / 4 # Angle de tir (rad)
height = 1.0 # Hauteur initiale du lancer (m)

# Fonction de trajectoire parabolique


def trajectoire_parabolique(t, v0, theta, height):
x = v0 * np.cos(theta) * t
y = height + v0 * np.sin(theta) * t - 0.5 * g * t**2
return x, y

# Simuler la trajectoire
t_max = 2 * v0 * np.sin(theta) / g
t = np.arange(0, t_max, dt)
x, y = trajectoire_parabolique(t, v0, theta, height)

# Trouver le point de rebond


indice_rebond = np.argmax(y < 0)
t_rebond = t[indice_rebond]
x_rebond, y_rebond = x[indice_rebond], y[indice_rebond]

# Nouvelle hauteur après le rebond


height_rebond = 0.0
# Simuler la trajectoire après le rebond
t_rebond_total = t_max - t_rebond
t_rebond_new = np.arange(0, t_rebond_total, dt)
x_rebond_new, y_rebond_new = trajectoire_parabolique(t_rebond_new, v0, theta, height_rebond)
x_rebond_new += x_rebond

# Fusionner les deux parties de la trajectoire


t_final = np.concatenate((t[:indice_rebond], t_rebond_new))
x_final = np.concatenate((x[:indice_rebond], x_rebond_new))
y_final = np.concatenate((y[:indice_rebond], y_rebond_new))

# Plot
# Terrain de tennis décalé
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot(x_final, t_final, y_final, label='Trajectoire de la balle')
ax.scatter(x_rebond, t_rebond, 0, color='red', label='Point de rebond')
ax.set_xlabel('X (m)')
ax.set_ylabel('Temps (s)')
ax.set_zlabel('Y (m)')
ax.set_title('Trajectoire 3D de la balle de tennis')
ax.legend()
plt.show()

Vous aimerez peut-être aussi