Hi all,
Please allow me to advertise this project I started: QuaTorch
Try it out with
pip install quatorch
The idea is to have lightweight package providing a subclass of torch.Tensor , namely, quatorch.Quaternion that follows the multiplication rules of quaternions. It also contain convenience functions such as, converting from/to rotations matrices, axis-angle representation, SLERP, and, of course, rotating a set of 3d vectors.
It supports default broadcasting in all operations as a quaternion is a tensor of shape (…, 4), i.e., with any number of leading dimensions. This let you do things like:
t = torch.linspace(0, 1, steps=10)[..., None]
r = q0.slerp(q_final, t).rotate_vector(torch.tensor([0.0, 1.0, -1.0]))
plt.scatter(r[:, 1], r[:, 2])
I notice some other implementations of quaternions out there in some packages (kornia, PyTorch3D, …) but the goal here is to have a lightweight dependency to work with quaternions in a more integrated way (i.e., as a torch.Tensor subclass). Ideally, these libraries would use QuaTorch as a dependency allowing user to operate seamlessly with quaternions between them.
Take a look:

