Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mutation_scale=20, lw=3, arrowstyle="-|>", color="k")
ax.add_artist(axis_arrow)
p1 = (unitx if np.abs(a[0]) <= np.finfo(float).eps else
perpendicular_to_vectors(unity, a[:3]))
p2 = perpendicular_to_vectors(a[:3], p1)
angle_p1p2 = angle_between_vectors(p1, p2)
arc = np.empty((100, 3))
for i, t in enumerate(np.linspace(0, 2 * a[3] / np.pi, 100)):
w1, w2 = _slerp_weights(angle_p1p2, t)
arc[i] = p + 0.5 * s * (a[:3] + w1 * p1 + w2 * p2)
ax.plot(arc[:-5, 0], arc[:-5, 1], arc[:-5, 2], color="k", lw=3, **kwargs)
arrow_coords = np.vstack((arc[-1], arc[-1] + 20 * (arc[-1] - arc[-3]))).T
angle_arrow = Arrow3D(
arrow_coords[0], arrow_coords[1], arrow_coords[2],
mutation_scale=20, lw=3, arrowstyle="-|>", color="k")
ax.add_artist(angle_arrow)
for i in [0, -1]:
arc_bound = np.vstack((p + 0.5 * s * a[:3], arc[i])).T
ax.plot(arc_bound[0], arc_bound[1], arc_bound[2], "--", c="k")
return ax
y_translation = 0.2
z_rotation = np.pi / 4.0
A2B = np.array([
[np.cos(z_rotation), -np.sin(z_rotation), 0.0, x_translation],
[np.sin(z_rotation), np.cos(z_rotation), 0.0, y_translation],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0]
])
PB = transform(A2B, PA)
plot_transform(ax=ax, A2B=np.eye(4))
ax.scatter(PA[:, 0], PA[:, 1], PA[:, 2], c="orange")
plot_transform(ax=ax, A2B=A2B, ls="--", alpha=0.5)
ax.scatter(PB[:, 0], PB[:, 1], PB[:, 2], c="cyan")
axis_arrow = Arrow3D(
[0.7, 0.3],
[0.4, 0.9],
[0.2, 0.2],
mutation_scale=20, lw=3, arrowstyle="-|>", color="k")
ax.add_artist(axis_arrow)
plt.tight_layout()
plt.show()
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)
x_translation = -0.1
y_translation = 0.2
z_rotation = np.pi / 4.0
A2B = np.array([
[np.cos(z_rotation), -np.sin(z_rotation), 0.0, x_translation],
[np.sin(z_rotation), np.cos(z_rotation), 0.0, y_translation],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0]
])
plot_transform(ax=ax, A2B=np.eye(4), ls="--", alpha=0.5)
ax.scatter(PA[:, 0], PA[:, 1], PA[:, 2], c="orange")
plot_transform(ax=ax, A2B=A2B)
axis_arrow = Arrow3D(
[0.0, -0.1],
[0.0, 0.2],
[0.2, 0.2],
mutation_scale=20, lw=3, arrowstyle="-|>", color="k")
ax.add_artist(axis_arrow)
plt.tight_layout()
plt.show()
def draw(self, renderer):
"""Draw the patch."""
xs3d, ys3d, zs3d = self._verts3d
xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
super(Arrow3D, self).draw(renderer)
ax_s : float, optional (default: 1)
Scaling of the new matplotlib 3d axis
kwargs : dict, optional (default: {})
Additional arguments for the plotting functions, e.g. alpha
Returns
-------
ax : Matplotlib 3d axis
New or old axis
"""
a = check_axis_angle(a)
if ax is None:
ax = make_3d_axis(ax_s)
axis_arrow = Arrow3D(
[p[0], p[0] + s * a[0]],
[p[1], p[1] + s * a[1]],
[p[2], p[2] + s * a[2]],
mutation_scale=20, lw=3, arrowstyle="-|>", color="k")
ax.add_artist(axis_arrow)
p1 = (unitx if np.abs(a[0]) <= np.finfo(float).eps else
perpendicular_to_vectors(unity, a[:3]))
p2 = perpendicular_to_vectors(a[:3], p1)
angle_p1p2 = angle_between_vectors(p1, p2)
arc = np.empty((100, 3))
for i, t in enumerate(np.linspace(0, 2 * a[3] / np.pi, 100)):
w1, w2 = _slerp_weights(angle_p1p2, t)
arc[i] = p + 0.5 * s * (a[:3] + w1 * p1 + w2 * p2)
ax.plot(arc[:-5, 0], arc[:-5, 1], arc[:-5, 2], color="k", lw=3, **kwargs)