Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
print(__doc__)
import numpy as np
import matplotlib.pyplot as plt
import pytransform3d.rotations as pyrot
import pytransform3d.transformations as pytr
p = np.array([0.0, 0.0, -0.5])
a = np.array([0.0, 0.0, 1.0, np.pi])
B2A = pytr.transform_from(pyrot.matrix_from_axis_angle(a), p)
p = np.array([0.3, 0.4, 0.5])
a = np.array([0.0, 0.0, 1.0, -np.pi / 2.0])
C2B = pytr.transform_from(pyrot.matrix_from_axis_angle(a), p)
C2A = pytr.concat(C2B, B2A)
p = pytr.transform(C2A, np.ones(4))
ax = pytr.plot_transform(A2B=B2A)
pytr.plot_transform(ax, A2B=C2A)
ax.scatter(p[0], p[1], p[2])
plt.show()
"""
print(__doc__)
import numpy as np
import matplotlib.pyplot as plt
from pytransform3d.rotations import (random_axis_angle, matrix_from_axis_angle,
plot_basis, plot_axis_angle)
original = random_axis_angle(np.random.RandomState(0))
ax = plot_axis_angle(a=original)
for fraction in np.linspace(0, 1, 50):
a = original.copy()
a[-1] = fraction * original[-1]
R = matrix_from_axis_angle(a)
plot_basis(ax, R, alpha=0.2)
plt.show()
"""
A2B = check_transform(A2B)
A2B_scaled = np.eye(4)
R = A2B[:3, :3]
t = A2B[:3, 3]
S_t = np.array([s_xt, s_yt, s_zt])
A2B_scaled[:3, 3] = s_d * s_t * S_t * t
a = axis_angle_from_matrix(R)
a_new = np.empty(4)
a_new[3] = s_d * s_r * a[3]
S_r = np.array([s_xr, s_yr, s_zr])
a_new[:3] = norm_vector(S_r * a[:3])
A2B_scaled[:3, :3] = matrix_from_axis_angle(a_new)
return A2B_scaled
Note that joint angles are clipped to their limits.
Parameters
----------
joint_name : string
Name of the joint
angle : float
Joint angle in radians
"""
if joint_name not in self._joints:
raise KeyError("Joint '%s' is not known" % joint_name)
from_frame, to_frame, child2parent, axis, limits = self._joints[joint_name]
angle = np.clip(angle, limits[0], limits[1])
joint_rotation = matrix_from_axis_angle(np.hstack((axis, [angle])))
joint2A = transform_from(joint_rotation, np.zeros(3))
self.add_transform(from_frame, to_frame, concat(joint2A, child2parent))