>>13311110If you just want a formula, check Wikipedia.
If you want to understand how it works, I can recommend this old textbook on quaternions from 1890
https://archive.org/details/117770257/page/n37/mode/2upIt's very wordy but it does the geometric derivations from the ground up
The quick and dirty explanation is that multiplying a vector by a purely imaginary quaternion like rotates the vector 90 degrees around the (x,y,z) axis. To get other angles we take a linear combination of the rotated vector and the original vector, which is why quaternions also have a real part.