Based on your function naming, I take it your just trying to set the rotation to a completely new rotation along that angle, as opposed to offsetting the rotation by a set amount.
In this case, rather than concatenating a quaternion to the current one, you can just create a new quaternion entirely. Note that you'll still probably want to pass in an x
, y
and z
value to the function, relating to the other text boxes, or the current rotations along those angles.
Here are the outlines for the formulae to working out each axis of a quaternion, assuming no prior code is in place to create these Euler conversions already (note, pseudocode to avoid language issues):
void EulerAnglesToQuaternion( Quaternion q , double x , double y , double z )
{
double cx = cos(x*0.5);
double cy = cos(y*0.5);
double cz = cos(z*0.5);
double sx = sin(x*0.5);
double sy = sin(y*0.5);
double sz = sin(z*0.5);
q.w = (cz*cx*cy)+(sz*sx*sy);
q.x = (cz*sx*cy)-(sz*cx*sy);
q.y = (cz*cx*sy)+(sz*sx*cy);
q.z = (sz*cx*cy)-(cz*sx*sy);
}