Again, just dropping this here so I know where to find it. The following will set up a 1 degree rotation around the x axis (in this case it’s just rotating a Unity transform by 1 degree in the x)

Quaternion q = a_activeMesh.m_meshFilter.gameObject.transform.rotation;
Quaternion q2 = create_from_axis_angle(1.0f, 0.0f, 0.0f, 1.0f * Time.deltaTime);
q = q * q2;
a_activeMesh.m_meshFilter.gameObject.transform.rotation = q;

Quaternion CreateFromAxisAngle(float x, float y, float z, float a)
{
// Here we calculate the sin( theta / 2) once for optimization
float factor = Mathf.Sin(a / 2.0f);
Quaternion q;
q.x = x * factor;
q.y = y * factor;
q.z = z * factor;
// Calcualte the w value by cos( theta / 2 )
q.w = Mathf.Cos(a / 2.0f );
return q.normalized;
}

### Like this:

Like Loading...

*Related*