I have a problem understanding quaternions rotation in OpenGL.
So far I have implemented all function and operators related to quaternions.They are definitely working right!.
However I can't find where I'm making the mistake within rotation function.

Let's say I have a a cube in 3d space at (xyz)`(1, 5, 2)` if I am not wrong the position in 4D is `p = 0 + i + 5j + 2k`, and the orientation and rotation `(0, 0, 0, 0)` in 4D space is `q = 1 + 0i + 0j + 0k` 

Now I want to rotate it by 30 degrees along y-axis.

 q = cos(a / 2) + (ix + jy + kz)sin(a/2)

So 30 degrees along y-axis is `q=0.96+0.25j` now:

 Pout = q * Pin * con(q)

 Q = q * Pin = (0.96 + 0.25j) * (0 + 1i + 5j + 2k) = -1.25 + 1.46 + 4.8 + 1.67

Shall I normalize it now or not?

 conj(q) = 0.96 - 0.25j
 Pout = Q * con(q) = 0 + 1.81 + 4.92 + 1.32

Normalized:

 q = 0 + 0.33i + 0.91j + 0.22k

This is definitely the wrong answer according to [this site][1]

Rotating the object along the Y-axis by 30 degrees from a point `(0,0,0)` gives the correct result just by computing `q`. If I use the above algorithm and multiply it by `Pin` I get `(0,0,0,0)`

Can you show me how to do it right step by step?

Also how do I to orbit one point along another. Lets say I have the given point above and I want it to orbit around the point `(2, 10, -2)` using quaternions.

And when I manage to get the correct quaternion, how do I use it in the proper way along with openGL `glRotatef`?

So far my program runs like this:

 1. Quaternion = x, y, z of object
 2. Compute Rotation by X degrees along axes.
 3. Quaternion to Axis Angle
 4. `glRotatef` (by result of point 3)
 5. Quaternion = result of point 2
 6. Go to point 2
 7. Go to step 1

Do I always have to change quaternions to Axis-angles, or is there another way which allow me to represent the rotation without conversion?

 [1]: http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/program/index.htm