frenet.py
Programme Python de l'Interros des Lycées
import numpy as np
import matplotlib.pyplot as plt
R0,V0 = 5,3
def VecteurPosition (t):
x = R0*np.cos(t*V0/R0)
y = R0*np.sin(t*V0/R0)
return x,y
def VecteurVitesse (t, h=1e-5):
x0, y0 = VecteurPosition (t-h)
x1, y1 = VecteurPosition (t+h)
vx = (x1 - x0)/(2*h)
vy = (y1 - y0)/(2*h)
return vx,vy
def VecteurAcceleration (t, h=1e-5):
vx0, vy0 = VecteurVitesse (t-h)
vx1, vy1 = VecteurVitesse (t+h)
ax = (vx1 - vx0)/(2*h)
ay = (vy0 - vy1)/(2*h)
return ax,ay
def TraceVecteurAcceleration (t):
x,y = VecteurPosition(t)
ax,ay = VecteurAcceleration (t)
plt.arrow (x,y,ax,ay,head_width=.2, length_includes_head=True)
plt.plot (x,y,'+b')