There is quaternion code in the pack, but it's not quite set up to be used to code rotation code.

When I came to this problem, I wrote some code to create 4x4 matricies which could be used to translate and rotate points in the vertex shader.

When I get home I'll look over what I have and share some. But yes, at the moment, you do have to write your own code.

Note that once you have the rotation matrix, you can simply multiply the vertex by it to rotate it in the shader. You could also do this outside the shader, effectively meaning you wouldn't need a shader, but in my view you want to make the card do the work it is specialized at doing (matrix math!)

By the way, I think I know how to modify the Quaternion code to actually be, um, useful for what Quaternions are supposed to be used for. You know, rotating stuff.

There aren't currently any tutorials for 'qpq*' or ones that take the stuff in Wikipedia and make it practical for a computer science type.

------

To rotate your points you can do this

`// create a quaternion to rotate 45 degrees on the z-axis (visually, rolling the points around the origin)`

// x,y,z,w : x,y,z = axis normal, w = angle in radians

// note: I'm not sure how well Quaternion included works with various arbitrary axes;

// I only use it with pure axes to repeat yaw, pitch and roll

Quaternion q = new Quaternion();

q.setFromAxisAngle(new Vector4f(0,0,1,(float)Math.PI*.25f));

// turn a point into a Quaternion

// like when you're working with GL vector4f's,

// points are just x,y,z,0 (w is always 0.)

Quaternion p = new Quaternion(1,1,1,0);

// now do the multiplication to rotate the point

// qpq* (where q* is the conjugate/negation -x,-y,-z,w of q)

// the inner 'mul' happens first to resolve the first argument to mulInverse

// mulInverse, per its header multiplies the first argument by the inverse of the second

// thus we do 'qp' inside, then (qp)q* outside.

p = Quaternion.mulInverse(Quaternion.mul(q,p,p),q,p);

System.out.println(p);

// should print out ~0,~sqrt(2),1,0 or, x=0,y=1.414,z=1

This is less efficient than creating the rotation matrix and sending it to a shader. But you can create a rotation matrix from the Quaternion! I'll come up with a quick demo tomorrow.