35 """Euclidean transformation representations."""
39 from amino.mixin import VecMixin, CopyEltsMixin, MatMixin
44 class Vec3(ctypes.Structure, VecMixin):
45 """Length-3 vectors"""
47 _fields_ = [(
"x", ctypes.c_double), (
"y", ctypes.c_double),
48 (
"z", ctypes.c_double)]
51 """Constructs a Vec3 object
53 * If arg is None, the object is unitialized.
54 * If arg is a list, the list elements are copied to the object.
59 super(Vec3, self).
__init__(arg[0], arg[1], arg[2])
71 """Ensures thing is a Vec3. If it's not, convert it."""
76 """Returns the identity Vec3."""
77 return Vec3([0, 0, 0])
80 """Sum-square-differences of self and other."""
81 return libamino.aa_tf_vssd(self, Vec3.ensure(other))
84 """2-norm (Euclidean) of self"""
85 return libamino.aa_tf_vnorm(self)
87 def __getitem__(self, key):
96 def __setitem__(self, key, item):
104 raise IndexError(key)
106 def cross(self, other):
107 """Computes the cross product"""
109 libamino.aa_tf_cross(self, Vec3.ensure(other), r)
112 def dot(self, other):
113 """Computes the dot product"""
114 return libamino.aa_tf_vdot(self, Vec3.ensure(other))
120 return 'Vec3((%f, %f, %f))' % (self.
xx, self.
yy, self.
zz)
122 def __iadd__(self, other):
123 if isinstance(other, Vec3):
138 def __add__(self, other):
139 return Vec3(self).__iadd__(other)
141 def __radd__(self, other):
142 return Vec3(self).__iadd__(other)
144 def __isub__(self, other):
145 if isinstance(other, Vec3):
160 """Subtracts a scalar or vector from self"""
162 return Vec3(self).__isub__(other)
165 """Subtracts self or vector from self"""
168 v.x = other - self.
xx
169 v.y = other - self.
yy
170 v.z = other - self.
zz
173 return Vec3(other).__isub__(self)
175 def __imul__(self, other):
183 def __mul__(self, other):
188 def __rmul__(self, other):
191 def __itruediv__(self, other):
199 def __truediv__(self, other):
200 return Vec3(self).__itruediv__(other)
203 """Converts to a quaternion and copies to h.
205 This functions sets the vector (xyz) part of h. The scalar
206 part (w) of h will be zero
215 class XAngle(ctypes.Structure):
216 """Rotation about the X axis"""
217 _fields_ = [(
"value", ctypes.c_double)]
220 """Converts to a quaternion and store in h"""
221 libamino.aa_tf_xangle2quat(self.value, h)
224 """Converts to a rotation matrix and store in r"""
225 libamino.aa_tf_xangle2rotmat(self.value, r)
228 """Converts to an axis-angle and store in a"""
229 libamino.aa_tf_xangle2axang(self.value, a)
232 """Converts to an Euler XYZ"""
238 return 'XAngle(%f)' % (self.value)
241 class YAngle(ctypes.Structure):
242 """Rotation about the Y axis"""
243 _fields_ = [(
"value", ctypes.c_double)]
246 """Converts to a quaternion and store in h"""
247 libamino.aa_tf_yangle2quat(self.value, h)
250 """Converts to a rotation matrix and store in r"""
251 libamino.aa_tf_yangle2rotmat(self.value, r)
254 """Converts to an axis-angle and store in a"""
255 libamino.aa_tf_yangle2axang(self.value, a)
258 """Converts to an Euler XYZ and store in e"""
264 return 'YAngle(%f)' % (self.value)
268 """Rotation about the Z axis"""
269 _fields_ = [(
"value", ctypes.c_double)]
272 """Converts to a quaternion and store in h"""
273 libamino.aa_tf_zangle2quat(self.value, h)
276 """Converts to a rotation matrix and store in r"""
277 libamino.aa_tf_zangle2rotmat(self.value, r)
280 """Converts to an axis-angle and store in a"""
281 libamino.aa_tf_zangle2axang(self.value, a)
284 """Converts to an Euler XYZ and store in e"""
290 return 'ZAngle(%f)' % (self.value)
294 """Z-Y-X Euler angles"""
295 _fields_ = [(
"_z", ctypes.c_double), (
"_y", ctypes.c_double),
296 (
"_x", ctypes.c_double)]
298 def __init__(self, arg=None):
300 super(EulerZYX, self).__init__(0, 0, 0)
301 elif isinstance(arg, (list, tuple)):
304 super(EulerZYX, self).__init__(arg[0], arg[1], arg[2])
306 arg.to_eulerzyx(self)
309 """Converts to a quaternion"""
310 libamino.aa_tf_eulerzyx2quat(self.
_z_z, self.
_y_y, self.
_x_x, h)
313 """Converts to a rotation matrix and store in r"""
314 libamino.aa_tf_eulerzyx2rotmat(self.
_z_z, self.
_y_y, self.
_x_x, r)
318 """X-axis rotation."""
327 """Y-axis rotation."""
336 """Z-axis rotation."""
344 return 'EulerZYX((%f, %f, %f))' % (self.
zzz, self.
yyy, self.
xxx)
348 """Roll-Pitch-Yaw Euler angles"""
350 def __init__(self, arg=None):
351 if isinstance(arg, (list, tuple)):
354 arg = (arg[2], arg[1], arg[0])
355 super(EulerRPY, self).__init__(arg)
385 return 'EulerRPY((%f, %f, %f))' % (self.
rrr, self.
ppp, self.
yyyyy)
388 class AxAng(ctypes.Structure):
389 """3D rotation about an arbitrary axis"""
390 _fields_ = [(
"axis", Vec3), (
"angle", ctypes.c_double)]
392 def __init__(self, arg=None):
398 def set_identity(self):
399 """Set to identity"""
400 self.axis.copy_from((0, 0, 1))
403 def conv_from(self, src):
404 """Converts src into an AxAng."""
405 if isinstance(src, (tuple, list)):
408 libamino.aa_tf_axang_make(src[0], src[1], src[2], src[3], self)
413 """Ensures the axis is a unit vector"""
414 libamino.aa_tf_axang_normalize(self)
418 """Converts to a quaternion"""
419 libamino.aa_tf_axang2quat(self, h)
422 """Converts to a rotation matrix and store in r"""
423 libamino.aa_tf_axang2rotmat(self, r)
426 """Converts to an axis-angle and store in a"""
427 a.axis.copy_from(self.axis)
428 a.angle = self.
angleangle
431 """Returns the inverse"""
434 a.angle = -self.
angleangle
438 """Rotate a point by self"""
440 libamino.aa_tf_axang_rot(self, Vec3.ensure(p), q)
445 angle = self.
angleangle
446 return 'AxAng((%f, %f, %f, %f))' % (axis.x, axis.y, axis.z, angle)
450 """Class for quaternions"""
452 (
"x", ctypes.c_double),
453 (
"y", ctypes.c_double),
454 (
"z", ctypes.c_double),
455 (
"w", ctypes.c_double),
458 def __init__(self, arg=None):
459 """Construct a Quat object
461 * If arg is None, the object is unitialized.
462 * If arg is a list, the list elements are copied to the object.
463 * If arg is an int or float, the scalar (w) of the object is set
464 and the vector (xyz) is zero
465 * If arg is a Vec3, the vector (xyz) of the object is set
466 and the scalar (w) is zero
467 * Else arg is converted to a Quat
475 """Converts src to a quaternion."""
481 elif isinstance(src, (list, tuple)):
489 """Returns the identity quaternion."""
494 """Ensures thing is a Quat. If it's not, convert it."""
495 return ensure(thing, Quat)
498 """Converts (copy) to a quaternion"""
505 """Converts to a rotation matrix and store in r"""
506 libamino.aa_tf_quat2rotmat(self, r)
509 """Converts to an axis-angle and store in a"""
510 libamino.aa_tf_quat2axang(self, a)
513 """Converts to an euler zyx angle representation"""
514 ang = (ctypes.c_double * 3)()
515 libamino.aa_tf_quat2eulerzyx(self, ang)
516 x = [ang[0], ang[1], ang[2]]
520 """Returns the vector (xyz) part"""
521 return Vec3([self.
xx, self.
yy, self.
zz])
524 """Returns the scalar (w) part"""
527 def ssd(self, other):
528 """Sum-square-differences of self and other."""
529 return libamino.aa_tf_qssd(self, Quat.ensure(other))
532 """2-norm (Euclidean) of self."""
533 return libamino.aa_tf_qnorm(self)
538 def __iadd__(self, other):
539 libamino.aa_tf_qiadd(self, Quat.ensure(other))
542 def __isub__(self, other):
543 libamino.aa_tf_qisub(self, Quat.ensure(other))
546 def __add__(self, other):
548 libamino.aa_tf_qadd(self, Quat.ensure(other), h)
551 def __radd__(self, other):
554 def __sub__(self, other):
556 libamino.aa_tf_qsub(self, Quat.ensure(other), h)
559 def __rsub__(self, other):
561 libamino.aa_tf_qsub(Quat.ensure(other), self, h)
565 """Normalize this object, i.e., divide by the magnitude."""
566 libamino.aa_tf_qnormalize(self)
570 """Converts to the minimal quaternion for the represented rotation."""
571 libamino.aa_tf_qminimize(self)
575 """Set to identity"""
588 def __imul__(self, other):
590 libamino.aa_tf_qscal(self, other)
595 def __rmul__(self, other):
597 return Quat(self).__imul__(other)
600 libamino.aa_tf_qmul(Quat.ensure(other), self, h)
603 def __mul__(self, other):
605 return Quat(self).__imul__(other)
608 libamino.aa_tf_qmul(self, Quat.ensure(other), h)
611 def __getitem__(self, key):
621 raise IndexError(key)
623 def __setitem__(self, key, item):
633 raise IndexError(key)
639 """Returns the conjugate"""
641 libamino.aa_tf_qconj(self, h)
645 """Returns the inverse"""
647 libamino.aa_tf_qinv(self, h)
651 """Returns the exponential"""
653 libamino.aa_tf_qexp(self, h)
657 """Returns the natural logarithm"""
659 libamino.aa_tf_qln(self, h)
663 """Rotate a point by this quaternion"""
665 libamino.aa_tf_qrot(self, Vec3.ensure(p), q)
669 return 'Quat((%f, %f, %f, %f))' % (self.
xx, self.
yy, self.
zz, self.
ww)
673 """Class for rotation matrices"""
674 _fields_ = [(
"cx", Vec3), (
"cy", Vec3), (
"cz", Vec3)]
677 """Construct a RotMat object
679 * If arg is None, the object is unitialized.
680 * If arg is 1, the object is the identity rotation matrix.
681 * Else arg is converted to a rotation matrix.
689 """Converts src to a rotation matrix."""
696 """Set to identity"""
697 self.cx.copy_from((1, 0, 0))
698 self.cy.copy_from((0, 1, 0))
699 self.cz.copy_from((0, 0, 1))
702 """Rotate a point."""
704 libamino.aa_tf_rotmat_rot(self, Vec3.ensure(p), q)
709 """Ensures thing is a RotMat. If it's not, convert it."""
710 return ensure(thing, RotMat)
713 """Chains two matrices"""
715 libamino.aa_tf_rotmat_mul(self, RotMat.ensure(other), r)
719 """Converts to a quaternion and store in h"""
720 libamino.aa_tf_rotmat2quat(self, h)
723 """Converts (copy) to a rotation matrix and store in r"""
729 """Converts to an axis-angle and store in a"""
730 libamino.aa_tf_rotmat2axang(self, a)
733 """Returns the natural logarithm"""
735 libamino.aa_tf_rotmat_lnv(self, h)
739 """Returns the inverse"""
741 libamino.aa_tf_rotmat_inv2(self, r)
744 def __getitem__(self, key):
752 raise IndexError(key)
754 def __setitem__(self, key, item):
763 raise IndexError(key)
767 """Number of rows."""
772 """Number of columns."""
777 """Constructs rotation matrix from rows in args."""
781 for i
in range(0, 3):
782 if len(args[i]) != 3:
784 for j
in range(0, 3):
790 """Constructs rotation matrix from columns in args."""
794 for j
in range(0, 3):
795 if len(args[j]) != 3:
797 for i
in range(0, 3):
802 return self.
_str_helper_str_helper(
"RotMat.row_matrix")
804 def isclose(self, other, tol=1e-9):
805 """Returns True if self is within tol rotation angle to other."""
806 other = RotMat.ensure(other)
807 v = (self * ~other).
ln().nrm2()
812 """Class for transformation matrices"""
813 _fields_ = [(
"R", RotMat), (
"v", Vec3)]
822 """Converts src to a transformation matrix."""
823 if isinstance(src, tuple):
828 self.
conv_fromconv_from((src.rotation, src.translation))
831 """Chains two TF matrices"""
833 libamino.aa_tf_tfmat_mul(self, other, r)
837 """Set to identity"""
839 self.v.copy_from((0, 0, 0))
842 """Returns the inverse"""
844 libamino.aa_tf_tfmat_inv2(self, h)
848 """Chains two TF matrices"""
850 libamino.aa_tf_tfmat_tf(self, Vec3.ensure(p), q)
864 """Translation part"""
869 return self.v.copy_from(value)
871 def __getitem__(self, key):
878 raise IndexError(key)
880 def __setitem__(self, key, item):
887 raise IndexError(key)
891 """Ensures thing is a TfMat. If it's not, convert it."""
892 return ensure(thing, TfMat)
896 """Constructs transformation matrix from rows in args."""
901 for i
in range(0, m):
905 for j
in range(0, n):
911 return self.
_str_helper_str_helper(
"TfMat.row_matrix", 3, 4)
918 """Class for Dual Number Quaternions"""
919 _fields_ = [(
"real", Quat), (
"dual", Quat)]
921 def __init__(self, arg=None):
928 """Set to identity"""
933 """Converts src to a Dual Quaternion."""
934 if isinstance(src, tuple):
936 libamino.aa_tf_qv2duqu(Quat.ensure(h), Vec3.ensure(v), self)
937 elif isinstance(src, list):
940 self.
conv_fromconv_from((src.rotation, src.translation))
943 """Chains two Dual Quaternions"""
945 libamino.aa_tf_duqu_mul(self, other, r)
949 """Returns the conjugate"""
951 libamino.aa_tf_duqu_conj(self, h)
955 """Returns the inverse"""
957 return self.
conjconj()
960 """Returns the dual quaternion logarithm"""
962 libamino.aa_tf_duqu_ln(self, h)
967 """Returns the identity dual quaternion."""
968 return DualQuat((Quat.identity(), Vec3.identity()))
972 """Ensures thing is a DualQuat. If it's not, convert it."""
976 """Real and dual parts 2-norm (Euclidean)"""
977 r = ctypes.c_double()
978 d = ctypes.c_double()
979 libamino.aa_tf_duqu_norm(self, ctypes.byref(r), ctypes.byref(d))
980 return (r.value, d.value)
983 """Transform point p"""
985 libamino.aa_tf_duqu_tf(self, Vec3.ensure(p), q)
991 def __getitem__(self, key):
1009 raise IndexError(key)
1012 def __setitem__(self, key, item):
1030 raise IndexError(key)
1039 return Quat(self.real)
1045 libamino.aa_tf_duqu_trans(self, v)
1052 libamino.aa_tf_qv2duqu(h, v, self)
1058 libamino.aa_tf_qv2duqu(h, v, self)
1062 """Class for Quaternion-Translation"""
1063 _fields_ = [(
"quat", Quat), (
"trans", Vec3)]
1065 def __init__(self, arg=None):
1072 """Set to identity"""
1077 """Converts src to quaternion-translation."""
1078 if isinstance(src, tuple):
1082 elif isinstance(src, list):
1085 self.
conv_fromconv_from((src.rotation, src.translation))
1089 """Returns the identity QuatTrans."""
1090 return QuatTrans((Quat.identity(), Vec3.identity()))
1094 """Ensures thing is a QuatTrans. If it's not, convert it."""
1095 return ensure(thing, QuatTrans)
1098 """Chains two Dual Quaternions"""
1100 libamino.aa_tf_qutr_mul(self, other, r)
1104 """Returns the conjugate"""
1106 libamino.aa_tf_qutr_conj(self, h)
1110 """Returns the inverse (same as conjugate)"""
1111 return self.
conjconj()
1114 """Chains two Quaternion-translations"""
1116 libamino.aa_tf_qutr_tf(self, Vec3.ensure(p), q)
1120 return 'QuatTrans((%s, %s))' % (self.quat, self.trans)
1122 def __getitem__(self, key):
1138 raise IndexError(key)
1141 def __setitem__(self, key, item):
1157 raise IndexError(key)
1184 class TfVec(ctypes.Structure):
1185 """six-element vector with rotational and translational parts."""
1186 _fields_ = [(
"trans", Vec3), (
"rot", Vec3)]
1195 def rotational(self):
1196 """Rotational part"""
1200 def translational(self):
1201 """Translational part"""
1204 @translational.setter
1205 def translational(self, x):
1206 """Set the translational part from x"""
1210 def rotational(self, x):
1211 """Set the rotational part from x"""
1215 """Copies src into self."""
1216 self.rotational = src.rotational
1217 self.translational = src.translational
1225 """Number of elements in self"""
1228 def __getitem__(self, key):
1230 raise IndexError(key)
1234 return self.
_second_second()[key - 3]
1236 raise IndexError(key)
1238 def __setitem__(self, key, item):
1240 raise IndexError(key)
1244 self.
_second_second()[key - 3] = item
1246 raise IndexError(key)
1248 def to_dvec(self, vec=DVec(6)):
1249 """Copies self to a vec."""
1254 """Copies vec to self."""
1259 """A rotational and translational velocity."""
1266 """A twist velocity."""
1276 libamino.aa_tf_xangle2quat.argtypes = [ctypes.c_double, ctypes.POINTER(Quat)]
1277 libamino.aa_tf_yangle2quat.argtypes = [ctypes.c_double, ctypes.POINTER(Quat)]
1278 libamino.aa_tf_zangle2quat.argtypes = [ctypes.c_double, ctypes.POINTER(Quat)]
1280 libamino.aa_tf_xangle2rotmat.argtypes = [
1281 ctypes.c_double, ctypes.POINTER(RotMat)
1283 libamino.aa_tf_yangle2rotmat.argtypes = [
1284 ctypes.c_double, ctypes.POINTER(RotMat)
1286 libamino.aa_tf_zangle2rotmat.argtypes = [
1287 ctypes.c_double, ctypes.POINTER(RotMat)
1290 libamino.aa_tf_xangle2axang.argtypes = [ctypes.c_double, ctypes.POINTER(AxAng)]
1291 libamino.aa_tf_yangle2axang.argtypes = [ctypes.c_double, ctypes.POINTER(AxAng)]
1292 libamino.aa_tf_zangle2axang.argtypes = [ctypes.c_double, ctypes.POINTER(AxAng)]
1294 libamino.aa_tf_eulerzyx2rotmat.argtypes = [
1295 ctypes.c_double, ctypes.c_double, ctypes.c_double,
1296 ctypes.POINTER(RotMat)
1299 libamino.aa_tf_eulerzyx2quat.argtypes = [
1300 ctypes.c_double, ctypes.c_double, ctypes.c_double,
1301 ctypes.POINTER(Quat)
1304 libamino.aa_tf_quat2eulerzyx.argtypes = [ctypes.POINTER(Quat),
1305 ctypes.POINTER(ctypes.c_double)]
1307 libamino.aa_tf_quat2rotmat.argtypes = [
1308 ctypes.POINTER(Quat), ctypes.POINTER(RotMat)
1310 libamino.aa_tf_rotmat2quat.argtypes = [
1311 ctypes.POINTER(RotMat), ctypes.POINTER(Quat)
1314 libamino.aa_tf_axang2quat.argtypes = [
1315 ctypes.POINTER(AxAng), ctypes.POINTER(Quat)
1317 libamino.aa_tf_quat2axang.argtypes = [
1318 ctypes.POINTER(Quat), ctypes.POINTER(AxAng)
1321 libamino.aa_tf_axang2rotmat.argtypes = [
1322 ctypes.POINTER(AxAng), ctypes.POINTER(RotMat)
1324 libamino.aa_tf_rotmat2axang.argtypes = [
1325 ctypes.POINTER(RotMat), ctypes.POINTER(AxAng)
1328 libamino.aa_tf_qv2duqu.argtypes = [
1329 ctypes.POINTER(Quat),
1330 ctypes.POINTER(Vec3),
1331 ctypes.POINTER(DualQuat)
1334 libamino.aa_tf_duqu2qv.argtypes = [
1335 ctypes.POINTER(DualQuat),
1336 ctypes.POINTER(Quat),
1337 ctypes.POINTER(Vec3)
1340 libamino.aa_tf_duqu2qv.argtypes = [
1341 ctypes.POINTER(DualQuat),
1342 ctypes.POINTER(Quat),
1343 ctypes.POINTER(Vec3)
1346 libamino.aa_tf_duqu_trans.argtypes = [
1347 ctypes.POINTER(DualQuat), ctypes.POINTER(Vec3)
1350 libamino.aa_tf_duqu_trans.argtypes = [
1351 ctypes.POINTER(DualQuat), ctypes.POINTER(Vec3)
1355 libamino.aa_tf_axang_make.argtypes = [
1356 ctypes.c_double, ctypes.c_double, ctypes.c_double, ctypes.c_double,
1357 ctypes.POINTER(AxAng)
1360 libamino.aa_tf_axang_normalize.argtypes = [ctypes.POINTER(AxAng)]
1362 libamino.aa_tf_axang_rot.argtypes = [
1363 ctypes.POINTER(AxAng),
1364 ctypes.POINTER(Vec3),
1365 ctypes.POINTER(Vec3)
1369 libamino.aa_tf_vssd.argtypes = [ctypes.POINTER(Vec3), ctypes.POINTER(Vec3)]
1370 libamino.aa_tf_vssd.restype = ctypes.c_double
1372 libamino.aa_tf_vnorm.argtypes = [ctypes.POINTER(Vec3)]
1373 libamino.aa_tf_vnorm.restype = ctypes.c_double
1375 libamino.aa_tf_vdot.argtypes = [ctypes.POINTER(Vec3), ctypes.POINTER(Vec3)]
1376 libamino.aa_tf_vdot.restype = ctypes.c_double
1378 libamino.aa_tf_cross.argtypes = [
1379 ctypes.POINTER(Vec3),
1380 ctypes.POINTER(Vec3),
1381 ctypes.POINTER(Vec3)
1386 libamino.aa_tf_qssd.argtypes = [ctypes.POINTER(Quat), ctypes.POINTER(Quat)]
1387 libamino.aa_tf_qssd.restype = ctypes.c_double
1389 libamino.aa_tf_qminimize.argtypes = [ctypes.POINTER(Quat)]
1391 libamino.aa_tf_qnorm.argtypes = [ctypes.POINTER(Quat)]
1392 libamino.aa_tf_qnorm.restype = ctypes.c_double
1394 libamino.aa_tf_qscal.argtypes = [ctypes.POINTER(Quat), ctypes.c_double]
1396 libamino.aa_tf_qnormalize.argtypes = [ctypes.POINTER(Quat)]
1398 libamino.aa_tf_qmul.argtypes = [
1399 ctypes.POINTER(Quat),
1400 ctypes.POINTER(Quat),
1401 ctypes.POINTER(Quat)
1403 libamino.aa_tf_qadd.argtypes = [
1404 ctypes.POINTER(Quat),
1405 ctypes.POINTER(Quat),
1406 ctypes.POINTER(Quat)
1408 libamino.aa_tf_qsub.argtypes = [
1409 ctypes.POINTER(Quat),
1410 ctypes.POINTER(Quat),
1411 ctypes.POINTER(Quat)
1413 libamino.aa_tf_qiadd.argtypes = [ctypes.POINTER(Quat), ctypes.POINTER(Quat)]
1414 libamino.aa_tf_qisub.argtypes = [ctypes.POINTER(Quat), ctypes.POINTER(Quat)]
1415 libamino.aa_tf_qinv.argtypes = [ctypes.POINTER(Quat), ctypes.POINTER(Quat)]
1416 libamino.aa_tf_qconj.argtypes = [ctypes.POINTER(Quat), ctypes.POINTER(Quat)]
1417 libamino.aa_tf_qexp.argtypes = [ctypes.POINTER(Quat), ctypes.POINTER(Quat)]
1418 libamino.aa_tf_qln.argtypes = [ctypes.POINTER(Quat), ctypes.POINTER(Quat)]
1420 libamino.aa_tf_qrot.argtypes = [
1421 ctypes.POINTER(Quat),
1422 ctypes.POINTER(Vec3),
1423 ctypes.POINTER(Vec3)
1428 libamino.aa_tf_rotmat_rot.argtypes = [
1429 ctypes.POINTER(RotMat),
1430 ctypes.POINTER(Vec3),
1431 ctypes.POINTER(Vec3)
1434 libamino.aa_tf_rotmat_mul.argtypes = [
1435 ctypes.POINTER(RotMat),
1436 ctypes.POINTER(RotMat),
1437 ctypes.POINTER(RotMat)
1440 libamino.aa_tf_rotmat_inv2.argtypes = [
1441 ctypes.POINTER(RotMat), ctypes.POINTER(RotMat)
1444 libamino.aa_tf_rotmat_lnv.argtypes = [
1445 ctypes.POINTER(RotMat), ctypes.POINTER(Vec3)
1449 libamino.aa_tf_tfmat_tf.argtypes = [
1450 ctypes.POINTER(TfMat),
1451 ctypes.POINTER(Vec3),
1452 ctypes.POINTER(Vec3)
1455 libamino.aa_tf_qutr_tf.argtypes = [
1456 ctypes.POINTER(QuatTrans),
1457 ctypes.POINTER(Vec3),
1458 ctypes.POINTER(Vec3)
1461 libamino.aa_tf_duqu_tf.argtypes = [
1462 ctypes.POINTER(DualQuat),
1463 ctypes.POINTER(Vec3),
1464 ctypes.POINTER(Vec3)
1467 libamino.aa_tf_duqu_ln.argtypes = [
1468 ctypes.POINTER(DualQuat),
1469 ctypes.POINTER(DualQuat)
1472 libamino.aa_tf_duqu_norm.argtypes = [
1473 ctypes.POINTER(DualQuat),
1474 ctypes.POINTER(ctypes.c_double),
1475 ctypes.POINTER(ctypes.c_double)
1478 libamino.aa_tf_tfmat_mul.argtypes = [
1479 ctypes.POINTER(TfMat),
1480 ctypes.POINTER(TfMat),
1481 ctypes.POINTER(TfMat)
1484 libamino.aa_tf_duqu_mul.argtypes = [
1485 ctypes.POINTER(DualQuat),
1486 ctypes.POINTER(DualQuat),
1487 ctypes.POINTER(DualQuat)
1490 libamino.aa_tf_qutr_mul.argtypes = [
1491 ctypes.POINTER(QuatTrans),
1492 ctypes.POINTER(QuatTrans),
1493 ctypes.POINTER(QuatTrans)
1496 libamino.aa_tf_tfmat_inv2.argtypes = [
1497 ctypes.POINTER(TfMat), ctypes.POINTER(TfMat)
1500 libamino.aa_tf_duqu_conj.argtypes = [
1501 ctypes.POINTER(DualQuat),
1502 ctypes.POINTER(DualQuat)
1505 libamino.aa_tf_qutr_conj.argtypes = [
1506 ctypes.POINTER(QuatTrans),
1507 ctypes.POINTER(QuatTrans)
1510 libamino.aa_tf_qutr_conj.argtypes = [
1511 ctypes.POINTER(QuatTrans),
1512 ctypes.POINTER(QuatTrans)
def copy_from(self, src)
Copy elements from src to self.
Mixin for matrix-like objects.
def _str_helper(self, name, m=None, n=None)
Mixin for vector-like objects.
3D rotation about an arbitrary axis
def to_axang(self, a)
Converts to an axis-angle and store in a.
def to_quat(self, h)
Converts to a quaternion.
def normalize(self)
Ensures the axis is a unit vecto.
def rotate(self, p)
Rotate a point by self.
def to_rotmat(self, r)
Converts to a rotation matrix and store in.
def __invert__(self)
Returns the inverse.
Class for Dual Number Quaternions.
def norm_parts(self)
Real and dual parts 2-norm (Euclidean)
def ln(self)
Returns the dual quaternion logarithm.
def identity()
Returns the identity dual quaternion.
def rotation(self, value)
def conv_from(self, src)
Converts src to a Dual Quaternion.
def conj(self)
Returns the conjugate.
def set_identity(self)
Set to identity.
def rotation(self)
Rotation part.
def translation(self)
Translation.
def transform(self, p)
Transform point p.
def translation(self, value)
def __invert__(self)
Returns the inverse.
def ensure(thing)
Ensures thing is a DualQuat.
Roll-Pitch-Yaw Euler angles.
def to_quat(self, h)
Converts to a quaternion.
def to_rotmat(self, r)
Converts to a rotation matrix and store in.
def y(self)
Y-axis rotation.
def x(self)
X-axis rotation.
def z(self)
Z-axis rotation.
Class for Quaternion-Translation.
def transform(self, p)
Chains two Quaternion-translations.
def conj(self)
Returns the conjugate.
def __mul__(self, other)
Chains two Dual Quaternions.
def ensure(thing)
Ensures thing is a QuatTrans.
def rotation(self)
Rotation part.
def conv_from(self, src)
Converts src to quaternion-translation.
def translation(self)
Translation.
def __invert__(self)
Returns the inverse (same as conjugate)
def rotate(self, p)
Rotate a point by this quaternion.
def ensure(thing)
Ensures thing is a Quat.
def ln(self)
Returns the natural logarithm.
def set_identity(self)
Set to identity.
def conv_from(self, src)
Converts src to a quaternion.
def __init__(self, arg=None)
Construct a Quat object.
def normalize(self)
Normalize this object, i.e., divide by the magnitude.
def conj(self)
Returns the conjugate.
def scalar(self)
Returns the scalar (w) part.
def exp(self)
Returns the exponential.
def ssd(self, other)
Sum-square-differences of self and other.
def to_quat(self, h)
Converts (copy) to a quaternion.
def __invert__(self)
Returns the inverse.
def identity()
Returns the identity quaternion.
def minimize(self)
Converts to the minimal quaternion for the represented rotation.
def vector(self)
Returns the vector (xyz) part.
def to_axang(self, a)
Converts to an axis-angle and store in a.
def to_rotmat(self, r)
Converts to a rotation matrix and store in.
def nrm2(self)
2-norm (Euclidean) of self.
def to_eulerzyx(self)
Converts to an euler zyx angle representation.
def zero(self)
Set to zero.
Class for rotation matrices.
def to_rotmat(self, r)
Converts (copy) to a rotation matrix and store in.
def to_quat(self, h)
Converts to a quaternion and store in h.
def col_matrix(args)
Constructs rotation matrix from columns in args.
def rotate(self, p)
Rotate a point.
def rows(self)
Number of rows.
def row_matrix(args)
Constructs rotation matrix from rows in args.
def __mul__(self, other)
Chains two matrices.
def __invert__(self)
Returns the inverse.
def conv_from(self, src)
Converts src to a rotation matrix.
def __init__(self, arg=None)
Construct a RotMat object.
def ensure(thing)
Ensures thing is a RotMat.
def cols(self)
Number of columns.
def set_identity(self)
Set to identity.
def isclose(self, other, tol=1e-9)
Returns True if self is within tol rotation angle to other.
def ln(self)
Returns the natural logarithm.
def to_axang(self, a)
Converts to an axis-angle and store in a.
Class for transformation matrices.
def translation(self)
Translation part.
def row_matrix(args)
Constructs transformation matrix from rows in args.
def __invert__(self)
Returns the inverse.
def transform(self, p)
Chains two TF matrices.
def __mul__(self, other)
Chains two TF matrices.
def set_identity(self)
Set to identity.
def conv_from(self, src)
Converts src to a transformation matrix.
def rotation(self)
Rotation part.
def ensure(thing)
Ensures thing is a TfMat.
six-element vector with rotational and translational parts.
def from_dvec(self, vec)
Copies vec to self.
def zero(self)
Set to zero.
def to_dvec(self, vec=DVec(6))
Copies self to a vec.
def __len__(self)
Number of elements in self.
A rotational and translational velocity.
def cross(self, other)
Computes the cross product.
def __iadd__(self, other)
def nrm2(self)
2-norm (Euclidean) of self
def dot(self, other)
Computes the dot product.
def __isub__(self, other)
def identity()
Returns the identity Vec3.
def __sub__(self, other)
Subtracts a scalar or vector from self.
def to_quat(self, h)
Converts to a quaternion and copies to h.
def zero(self)
Sets to zero.
def ssd(self, other)
Sum-square-differences of self and other.
def __rsub__(self, other)
Subtracts self or vector from self.
def __init__(self, arg=None)
Constructs a Vec3 object.
def ensure(thing)
Ensures thing is a Vec3.
Rotation about the X axis.
def to_quat(self, h)
Converts to a quaternion and store in h.
def to_rotmat(self, r)
Converts to a rotation matrix and store in.
def to_eulerzyx(self, e)
Converts to an Euler XYZ.
def to_axang(self, a)
Converts to an axis-angle and store in a.
Rotation about the Y axis.
def to_rotmat(self, r)
Converts to a rotation matrix and store in.
def to_eulerzyx(self, e)
Converts to an Euler XYZ and store in e.
def to_quat(self, h)
Converts to a quaternion and store in h.
def to_axang(self, a)
Converts to an axis-angle and store in a.
Rotation about the Z axis.
def to_axang(self, a)
Converts to an axis-angle and store in a.
def to_eulerzyx(self, e)
Converts to an Euler XYZ and store in e.