I met a issue when trying to convert a quaternion into a rotation matrix.
Let's assume that I want to have a rotation around one axis that has one point at the origin and one point at: x=1, y=1, z=1. I want to made a rotation of 50 degrees around this axis.
To convert this rotation axis to a quaternion I need to normalize my vector.
Modulo of my vector =sqrt ( 1*1 + 1*1 +1*1) = 1.7320508075688772
then I normalize it
x=x/length y=y/length z=z/length
0.5773502691896258 0.57735026918962580.5773502691896258
I convert the angle in radiants
angle= 50 / 180 * pi =0.8726646259971648
the quaternion then is:
qw = cos(angle/2) = 0.9063077870366499
qx = x * sin( angle/2 ) = 0.24399876718044458
qy = y * sin( angle/2 ) = 0.24399876718044458
qz = z * sin( angle/2 ) = 0.24399876718044458
I verify if the quaternion has modulo 1 by doing
sqr(w*w + x*x + y*y + z*z) = 1
Then I convert the quaternion to a rotation matrix using this formula

1 - 2*qy2 - 2*qz2 2*qx*qy - 2*qz*qw 2*qx*qz + 2*qy*qw
2*qx*qy + 2*qz*qw 1 - 2*qx2 - 2*qz2 2*qy*qz - 2*qx*qw
2*qx*qz - 2*qy*qw 2*qy*qz + 2*qx*qw 1 - 2*qx2 - 2*qy2


And I got this result

0.7618584064576928 -0.32320516867480537 0.5613467622171125
0.5613467622171125 0.7618584064576928 0.5613467622171125
-0.32320516867480537 -0.32320516867480537 0.7618584064576928

To verify if the matrix is correct I sum the squares of each row and column


0.7618584064576928 -0.32320516867480537 0.5613467622171125 1
0.5613467622171125 0.7618584064576928 0.5613467622171125 1.2106486064 (not correct)
-0.32320516867480537 -0.32320516867480537 0.7618584064576928 0.7893513936 (not correct)
1 0.7893513936 (not correct) 1.2106486064 (not correct)

This shows that my rotation matrix is not correct. I have found that if the rotation axis is along X, Y or Z this doesn't happen: in these cases the rotation matrix is correct.But if the axis is not aligned to an axis the rotation matrix comes out not correct. Why this happens?