Beispiel #1
0
def mult_q_q(q1, q2):
	if CYTHON_CFASTMATH:
		return CFastMath.mult_q_q(q1, q2)
	else:
		x0 = q1[0]*q2[0] - q1[1]*q2[1] - q1[2]*q2[2] - q1[3]*q2[3]
		x1 = q1[0]*q2[1] + q1[1]*q2[0] + q1[2]*q2[3] - q1[3]*q2[2]
		x2 = q1[0]*q2[2] - q1[1]*q2[3] + q1[2]*q2[0] + q1[3]*q2[1]
		x3 = q1[0]*q2[3] + q1[1]*q2[2] - q1[2]*q2[1] + q1[3]*q2[0]
		return np.array([x0, x1, x2, x3])
Beispiel #2
0
def mult_q_q(q1, q2):
    if CYTHON_CFASTMATH:
        return CFastMath.mult_q_q(q1, q2)
    else:
        x0 = q1[0] * q2[0] - q1[1] * q2[1] - q1[2] * q2[2] - q1[3] * q2[3]
        x1 = q1[0] * q2[1] + q1[1] * q2[0] + q1[2] * q2[3] - q1[3] * q2[2]
        x2 = q1[0] * q2[2] - q1[1] * q2[3] + q1[2] * q2[0] + q1[3] * q2[1]
        x3 = q1[0] * q2[3] + q1[1] * q2[2] - q1[2] * q2[1] + q1[3] * q2[0]
        return np.array([x0, x1, x2, x3])
Beispiel #3
0
	def __mul__(self, other):
		if isinstance(other, Number):
			return Quaternion(q=self.q * other, dtype=self.dtype)
		elif CYTHON_CFASTMATH:
			return Quaternion(CFastMath.mult_q_q(self.q, other.q))
		else:
			q1 = self.q
			q2 = other.q
			x0 = q1[0]*q2[0] - q1[1]*q2[1] - q1[2]*q2[2] - q1[3]*q2[3]
			x1 = q1[0]*q2[1] + q1[1]*q2[0] + q1[2]*q2[3] - q1[3]*q2[2]
			x2 = q1[0]*q2[2] - q1[1]*q2[3] + q1[2]*q2[0] + q1[3]*q2[1]
			x3 = q1[0]*q2[3] + q1[1]*q2[2] - q1[2]*q2[1] + q1[3]*q2[0]
			return Quaternion(q=[x0, x1, x2, x3], dtype=self.dtype)
Beispiel #4
0
 def __mul__(self, other):
     if isinstance(other, Number):
         return Quaternion(q=self.q * other, dtype=self.dtype)
     elif CYTHON_CFASTMATH:
         return Quaternion(CFastMath.mult_q_q(self.q, other.q))
     else:
         q1 = self.q
         q2 = other.q
         x0 = q1[0] * q2[0] - q1[1] * q2[1] - q1[2] * q2[2] - q1[3] * q2[3]
         x1 = q1[0] * q2[1] + q1[1] * q2[0] + q1[2] * q2[3] - q1[3] * q2[2]
         x2 = q1[0] * q2[2] - q1[1] * q2[3] + q1[2] * q2[0] + q1[3] * q2[1]
         x3 = q1[0] * q2[3] + q1[1] * q2[2] - q1[2] * q2[1] + q1[3] * q2[0]
         return Quaternion(q=[x0, x1, x2, x3], dtype=self.dtype)