import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
# Quaternion utility functions
def quat_mult(q1, q2):
# Hamilton product of two quaternions q = [w, x, y, z]
w1, x1, y1, z1 = q1
w2, x2, y2, z2 = q2
w = w1*w2 - x1*x2 - y1*y2 - z1*z2
x = w1*x2 + x1*w2 ...