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

Method __rmul__

python/pymesh/misc/quaternion.py:119–135  ·  view source on GitHub ↗

Multiplication: ``other`` * ``self`` This method is called only if other is not a :class:`Quaternion`. 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

117 return r
118
119 def __rmul__(self, other):
120 """ Multiplication: ``other`` * ``self``
121
122 This method is called only if other is not a :class:`Quaternion`.
123
124 Args:
125 ``other`` (:class:`Quaternion` or ``numpy.ndarray``): If it is of
126 type ``numpy.ndarray``, it must be normalized.
127 """
128 r = Quaternion()
129 a = other
130 b = self
131 r[0] = a[0]*b[0] - a[1]*b[1] - a[2]*b[2] - a[3]*b[3]
132 r[1] = a[0]*b[1] + a[1]*b[0] + a[2]*b[3] - a[3]*b[2]
133 r[2] = a[0]*b[2] - a[1]*b[3] + a[2]*b[0] + a[3]*b[1]
134 r[3] = a[0]*b[3] + a[1]*b[2] - a[2]*b[1] + a[3]*b[0]
135 return r
136
137 def to_matrix(self):
138 """ Convert to rotational matrix.

Callers

nothing calls this directly

Calls 1

QuaternionClass · 0.85

Tested by

no test coverage detected