Ajout de la représentation 3D

main
Gaël Pongnot 2 years ago
parent a156905d25
commit df79768e96
  1. 66
      MLI_vectorielle.py

@ -6,6 +6,7 @@ import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, Button, CheckButtons
from matplotlib.axes import Axes
from matplotlib.projections.polar import PolarAxes
from mpl_toolkits.mplot3d.axes3d import Axes3D
PI = np.pi
@ -205,6 +206,65 @@ class TriPlot_VectAxe(PolarAxes):
return
class TriPlot_3DAxe(Axes3D):
"""Classe d'axe 3D"""
phase = 2*PI/3*np.array([0, 1, 2])
phasor = np.linspace(0-phase, 2*PI-phase, N_PTS).T
theta = phasor[0,:]
def __init__(self, v_max, phi, fig, rect, *args, **kwargs):
Axes3D.__init__(self, fig, rect, auto_add_to_figure=False,
*args, **kwargs)
self.plot_list = []
self.arrow_list = []
self.v_max = v_max
self.phi = phi
self.v_re = np.zeros(self.phasor.shape)
self.v_im = np.zeros(self.phasor.shape)
return
def setup(self):
self.get_figure().add_axes(self)
for i in range(3):
self.plot_list.append(
self.plot(self.v_re[i,:], self.v_im[i,:],
self.theta
)[0]
)
self.set_xlim([-1.6*self.v_max, 1.6*self.v_max])
self.set_ylim([-1.6*self.v_max, 1.6*self.v_max])
self.view_init(vertical_axis='y')
self.set_zlim([0, 2*PI])
self.set_zticks([i*PI/6 for i in range(13)])
self.set_zticklabels([str(30*i)+"°" for i in range(13)])
self.set_box_aspect((4,1,1))
self.set_facecolor("#00000000")
return
def set_vmax(self, v_max):
self.v_max = v_max
self.v_re = self.v_max*np.cos(self.phasor)
self.v_im = self.v_max*np.sin(self.phasor)
return
def set_phi(self, phi):
self.phi = phi
return
def set_parameters(self, p):
return
def refresh(self):
for i, plot in enumerate(self.plot_list):
plot.set_data_3d(
self.v_re[i,:],
self.v_im[i,:],
self.theta
)
return
class TriPlot:
"""Classe de graphique MLI"""
@ -222,10 +282,12 @@ class TriPlot:
# Attributs graphiques
self.fig = plt.figure()
self.timeaxe = TriPlot_TimeAxe(self.v_max, self.phi,
self.fig, [0.1, 0.2, 0.4, 0.6])
self.fig, [0.1, 0.5, 0.4, 0.4])
self.vectaxe = TriPlot_VectAxe(self.v_max, self.phi,
self.fig, [0.5, 0.2, 0.5, 0.6])
self.axes = [self.timeaxe, self.vectaxe]
self.axe3D = TriPlot_3DAxe(self.v_max, self.phi,
self.fig, [0.1, -0.15, 0.4, 0.8])
self.axes = [self.vectaxe, self.timeaxe, self.axe3D]
self.amp_slider = Slider(
ax=plt.axes([0.01, 0.1, 0.03, 0.8]),
label="Tension\nefficace",

Loading…
Cancel
Save