rstellen einer einheitlichen zufälligen Quaternion und Multiplikation zweier Quaternion
Ich habe eine Python (NumPy) -Funktion, die eine einheitliche zufällige Quaternion erzeugt. Ich möchte zwei Quaternionenmultiplikation als zweidimensionales zurückgegebenes Array von derselben oder einer anderen Funktion erhalten. Die Formel der Quaternionenmultiplikation in meinem letzten Fall ist Q1 * Q2 und Q2 * Q1. Hier,Q1=(w0, x0, y0, z0)
undQ2=(w1, x1, y1, z1)
sind zwei Quaternionen. Die erwartete Ausgabe der Zwei-Quaternionen-Multiplikation (als 2-d-zurückgegebenes Array) sollte @ sei
return([-x1*x0 - y1*y0 - z1*z0 + w1*w0, x1*w0 + y1*z0 - z1*y0 +
w1*x0, -x1*z0 + y1*w0 + z1*x0 + w1*y0, x1*y0 - y1*x0 + z1*w0 +
w1*z0])
ann mir bitte jemand helfen? Meine Codes sind hier:
def randQ(N):
#Generates a uniform random quaternion
#James J. Kuffner 2004
#A random array 3xN
s = random.rand(3,N)
sigma1 = sqrt(1.0 - s[0])
sigma2 = sqrt(s[0])
theta1 = 2*pi*s[1]
theta2 = 2*pi*s[2]
w = cos(theta2)*sigma2
x = sin(theta1)*sigma1
y = cos(theta1)*sigma1
z = sin(theta2)*sigma2
return array([w, x, y, z])