MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / __mul__

Method __mul__

python/pymesh/misc/quaternion.py:103–117  ·  view source on GitHub ↗

Multiplication: ``self`` * ``other`` Args: ``other`` (:class:`Quaternion` or ``numpy.ndarray``): If it is of type ``numpy.ndarray``, it must be normalized.

(self, other)

Source from the content-addressed store, hash-verified

101 self.__quat[i] = val
102
103 def __mul__(self, other):
104 """ Multiplication: ``self`` * ``other``
105
106 Args:
107 ``other`` (:class:`Quaternion` or ``numpy.ndarray``): If it is of
108 type ``numpy.ndarray``, it must be normalized.
109 """
110 r = Quaternion()
111 a = self
112 b = other
113 r[0] = a[0]*b[0] - a[1]*b[1] - a[2]*b[2] - a[3]*b[3]
114 r[1] = a[0]*b[1] + a[1]*b[0] + a[2]*b[3] - a[3]*b[2]
115 r[2] = a[0]*b[2] - a[1]*b[3] + a[2]*b[0] + a[3]*b[1]
116 r[3] = a[0]*b[3] + a[1]*b[2] - a[2]*b[1] + a[3]*b[0]
117 return r
118
119 def __rmul__(self, other):
120 """ Multiplication: ``other`` * ``self``

Callers

nothing calls this directly

Calls 1

QuaternionClass · 0.85

Tested by

no test coverage detected