Last but not least, we can use the quaternion to $4 \times 4$ matrix conversion to return a matrix we can use to multiply with so it can be integrated with our project's other operations:
$$
\begin{aligned}
& \text { def get_matrix(self) : } \\
& \text { x2 }=\operatorname{self} \cdot x+\operatorname{self} \cdot x \\
& y^2=\operatorname{self} \cdot y+\operatorname{self} \cdot y \\
& z 2=\operatorname{self} \cdot z+\operatorname{self} \cdot z
\end{aligned}
$$
xx2 = self.x * x2
xy2 = self.x * y2
xz2 = self.x * z2
yy2 = self.y * y2
yz2 = self.y * z2
zz2 = self.z * z2
wx2 = self.w * x2
wy2 = self.w * y2
wz2 = self.w * z2
return np.matrix([
[1 - (yy2 + zz2), xy2 + wz2, xz2 - wy2,
0],
[ xy2 - wz2, 1 - (xx2 + zz2), yz2 + wx2,
0],
[xz2 + wy2, yz2 - wx2, 1 - (xx2 + yy2),
0],
[0, 0, 0, 1]
])