I have been trying to convert euler angles to quaternions and have not been able to do ether. I would like to be able to take a vector and apply a quaternion to it. I have searched google many times but could not find a solution. Please help.
Well...
1. rotate() ignores pos1.
2. rotate() only rotates around the Z axis. You'd normally want to at least be able to rotate around any of the three axes, and ideally around an arbitrary non-orthogonal axis.
That is actually a multiplication of a 2D vector with a 2x2 matrix: http://en.wikipedia.org/wiki/Rotation_matrix
However, as you should notice, your matrix had odd values and therefore won't rotate as usual.
The rotate() is definitely wrong: Lets take (1,0,0) and turn it 90 degrees around Z. That should yield (0,1,0). However, you compute new Y as k*Y, and since Y is 0, no k will turn it to 1. Same with X.
Your method of calculating the quat does not create a valid quaternion.