My question, however, is wmether I have to normalize the vector U or not,
and whether an SFRotation of (1 1 0 3.14) should behave any differently
from (.5 .5 0 3.14), i.e. is the vector in SFRotation *just* direction or
does the magnitude matter?
The code (note that I am precomputing some values for esadability and
efficiency):
costheta = cos(theta);
icostheta = 1.0 - costheta;
sintheta = sin(theta);
xx = x * x;
xy = x * y;
xz = x * z;
yy = y * y;
yz = y * z;
zz = z * z;
result->vals[0][0] = xx + ((1.0 - xx) * costheta);
result->vals[0][1] = (xy * icostheta) + (z * sintheta);
result->vals[0][2] = (xz * icostheta) - (y * sintheta);
result->vals[1][0] = (xy * icostheta) - (z * sintheta);
result->vals[1][1] = yy + ((1.0 - yy) * costheta);
result->vals[1][2] = (yz * icostheta) + (x * sintheta);
result->vals[2][0] = (xz * icostheta) + (y * sintheta);
result->vals[2][1] = (yz * icostheta) - (x * sintheta);
result->vals[2][2] = zz + ((1.0 - zz) * costheta);
Does anyone have any comments on the correctness or efficiency of this code?
--Greg