- struct ao_quaternion point;
-
- /* The amount of rotation is just the length of the vector. Now,
- * here's the trick -- assume that the rotation amount is small. In this case,
- * sin(x) ≃ x, so we can just make this the sin.
- */
-
- n_2 = x*x + y*y + z*z;
- n = sqrtf(n_2);
- s = n / 2;
- if (s > 1)
- s = 1;
- c = sqrtf(1 - s*s);
-
- /* Make unit vector */
- if (n > 0) {
- x /= n;
- y /= n;
- z /= n;
- }
-
- /* Now compute the unified rotation quaternion */
-
- ao_quaternion_init_rotation(&rot,
- x, y, z,
- s, c);