in src/plots.py [0:0]
def plot(self, p, v=None, scale=1, p_colors="blue", l_colors="blue", center=np.zeros(3), speed=1,
debug_markers=[], camera_rotation_speed=0, fps=None):
if scale != self.scale:
self.scale = scale
self.view.camera.distance = self.scale * 5
self.center = center
self.update_axis()
_p = p if len(p.shape) == 3 else np.array([p])
if v is not None:
_v = v if len(v.shape) == 3 else np.array([v])
else:
_v = None
_p = _p[:] - center
_v = _v[:] - center if _v is not None else np.array([])
debug_markers = debug_markers[:] - center if len(debug_markers) > 0 else debug_markers
config = dict(face_color=p_colors, symbol='o', size=3, edge_width=1, edge_color=p_colors)
config_debug = dict(face_color="grey", symbol='x', size=3, edge_width=1, edge_color="grey")
config_line = dict(width=5, color=l_colors, connect="segments")
if len(_v) > 0 and self.line_plot is None:
self.line_plot = self.Line3D(parent=self.view.scene, antialias=True)
self.line_plot.set_gl_state('translucent', blend=True, depth_test=True)
if len(debug_markers) > 0:
self.scatter_debug_plot.set_data(debug_markers, **config_debug)
if fps is None:
fps = speed * 60
p_idx = 0
start_time = time.time()
while p_idx < len(_p) - 1:
delta_time = (time.time() - start_time)
p_idx = min(int(delta_time * fps), len(_p) - 1)
if camera_rotation_speed != 0:
self.view.camera.azimuth = p_idx / speed / 3 * camera_rotation_speed + 130
if isinstance(p_colors, np.ndarray) and len(p_colors.shape) >= 2 and p_colors.shape[0] == len(_p):
config["face_color"] = p_colors[p_idx]
config["edge_color"] = p_colors[p_idx]
self.scatter_plot.set_data(_p[p_idx], **config)
if len(_v) > p_idx:
if isinstance(l_colors, np.ndarray) and len(l_colors.shape) >= 2 and l_colors.shape[0] == len(_p):
config_line["color"] = l_colors[p_idx]
if isinstance(l_colors, np.ndarray) and len(l_colors.shape) == 2:
config_line["color"] = l_colors
self.line_plot.set_data(_v[p_idx], **config_line)
self.canvas.update()
self.canvas.app.process_events()
self.canvas.app.process_events()
print(f"\r{p_idx}", end="")
time.sleep(0.016)