8 """ Dual quaternion class """
11 """ Dual quaternion consists of a real quaternion, and an infinitesimal
17 """ dual quaternion multiplication """
19 self.
real_q * right.inf_q +
20 self.
inf_q * right.real_q)
23 """ scalar division """
27 return "( " + repr(self.
real_q) + \
28 " + " + repr(self.
inf_q) +
")"
31 assert (key >= 0
and key < 8)
35 return self.
inf_q[i - 4]
38 """ squared norm when considering the dual quaternion as 8-tuple """
42 """ dual quaternion conjugate """
46 """ dual quaternion inverse """
58 sophus.Quaternion.zero())
61 if isinstance(self, other.__class__):
62 return self.
real_q == other.real_q
and self.
inf_q == other.inf_q
68 w, s0, s1, s2 = sympy.symbols(
'w s0 s1 s2', real=
True)
69 x, t0, t1, t2 = sympy.symbols(
'x t0 t1 t2', real=
True)
70 y, u0, u1, u2 = sympy.symbols(
'y u0 u1 u2', real=
True)
71 z, v0, v1, v2 = sympy.symbols(
'z v0 v1 v2', real=
True)
73 s = sophus.Vector3(s0, s1, s2)
74 t = sophus.Vector3(t0, t1, t2)
75 u = sophus.Vector3(u0, u1, u2)
76 v = sophus.Vector3(v0, v1, v2)
83 product = self.
a * self.
a.inv()
84 self.assertEqual(product.simplify(),
85 DualQuaternion.identity())
86 product = self.
a.inv() * self.
a
87 self.assertEqual(product.simplify(),
88 DualQuaternion.identity())
91 if __name__ ==
'__main__':