public static void TransformY(float y, ref Quaternion rotation, out Vector3 result)
{
//This operation is an optimized-down version of v' = q * v * q^-1.
//The expanded form would be to treat v as an 'axis only' quaternion
//and perform standard quaternion multiplication. Assuming q is normalized,
//q^-1 can be replaced by a conjugation.
float x2 = rotation.X + rotation.X;
float y2 = rotation.Y + rotation.Y;
float z2 = rotation.Z + rotation.Z;
float xx2 = rotation.X * x2;
float xy2 = rotation.X * y2;
float yz2 = rotation.Y * z2;
float zz2 = rotation.Z * z2;
float wx2 = rotation.W * x2;
float wz2 = rotation.W * z2;
//Defer the component setting since they're used in computation.
float transformedX = y * (xy2 - wz2);
float transformedY = y * (1f - xx2 - zz2);
float transformedZ = y * (yz2 + wx2);
result.X = transformedX;
result.Y = transformedY;
result.Z = transformedZ;
}