Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, H, show_direction=True, n_frames=10, s=1.0, **kwargs):
super(Trajectory, self).__init__()
self.show_direction = show_direction
self.trajectory = Line3D([], [], [], **kwargs)
self.key_frames = [Frame(np.eye(4), s=s, **kwargs)
for _ in range(n_frames)]
if self.show_direction:
self.direction_arrow = Arrow3D(
[0, 0], [0, 0], [0, 0],
mutation_scale=20, lw=1, arrowstyle="-|>", color="k")
self.set_data(H)
-------
ax : Matplotlib 3d axis
New or old axis
"""
if ax is None:
ax = make_3d_axis(ax_s)
if R is None:
R = np.eye(3)
R = check_matrix(R)
A2B = np.eye(4)
A2B[:3, :3] = R
A2B[:3, 3] = p
frame = Frame(A2B, s=s, **kwargs)
frame.add_frame(ax)
return ax
kwargs : dict, optional (default: {})
Additional arguments for the plotting functions, e.g. alpha
Returns
-------
ax : Matplotlib 3d axis
New or old axis
"""
if ax is None:
ax = make_3d_axis(ax_s)
if A2B is None:
A2B = np.eye(4)
A2B = check_transform(A2B)
frame = Frame(A2B, name, s, **kwargs)
frame.add_frame(ax)
return ax
def __init__(self, A2B, label=None, s=1.0, **kwargs):
super(Frame, self).__init__()
if "c" in kwargs:
kwargs.pop("c")
if "color" in kwargs:
kwargs.pop("color")
self.s = s
self.x_axis = Line3D([], [], [], color="r", **kwargs)
self.y_axis = Line3D([], [], [], color="g", **kwargs)
self.z_axis = Line3D([], [], [], color="b", **kwargs)
self.draw_label = label is not None
self.label = label
if self.draw_label:
if __name__ == "__main__":
n_frames = 50
fig = plt.figure(figsize=(5, 5))
ax = fig.add_subplot(111, projection="3d")
ax.set_xlim((-1, 1))
ax.set_ylim((-1, 1))
ax.set_zlim((-1, 1))
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_zlabel("Z")
frame = Frame(np.eye(4), label="rotating frame", s=0.5)
frame.add_frame(ax)
anim = animation.FuncAnimation(
fig, update_frame, n_frames, fargs=(n_frames, frame), interval=50,
blit=False)
plt.show()