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
|
import numpy as np
import matplotlib.pyplot as plt
from math import sqrt
#On considère une particule qui part de x=0 et y=0 à t=0 (0,0,0).
n=10 #nbr de pas
x=[]
y=[]
z=[]
xx=0.
yy=0.
zz=0.
x.append(xx)
y.append(yy)
z.append(zz)
for i in range(n) :
a=np.random.random()-1./2.
b=np.random.random()-1./2.
c=np.random.random()-1./2.
r=sqrt(a*a+b*b+c*c)
a=a/r
b=b/r
c=c/r
xx=xx+a
yy=yy+b
zz=zz+c
x.append(xx)
y.append(yy)
z.append(zz)
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot(x, y, z, label='représentation Z^3 n=100')
ax.legend()
plt.show() |
Partager