class quaternion:
__slots__ = ("x", "y", "z", "w")
def __init__(self, x: float, y: float, z: float, w: float):
self.x = x
self.y = y
self.z = z
self.w = w
def rotate(self, x: float, y: float, z: float):
# Correctly bump self.x, self.y, self.z, self.w with the provided radians
I'm implementing quaternion rotations in my code for cases where euler vectors are the lesser option. I have functions to set them and retrieve the forward / right / up vectors, but can't find good examples of how to apply a rotation. Unlike eulers I can't just bump x, y, z, w individually: Each modification to one axis must reflect on the others, and I need quaternions to rotate along their selves so for example if I want to bump it by a rotation of -0.1 on the X axis I want the object to rotate to its own left considering its pitch and roll.