SFRotation to Matrix question

Antmeopohedron ([email protected])
Sat, 21 Oct 1995 10:10:54 -0400 (EDT)


Well, I've been working on that transformations-to-matrix program I was
talking about and I have come across a curiosity. Looking in a book (Intro.
to Comp. Graphics; Foley, Van Dam, Feiner, Hughes, Phillips), I find a
matrix representation of an arbitrary rotation theta around an arbitrary
vector U(x, y, z). The matrix only involves the top left 3x3 of the generic
4x4, and the code for it is below.

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


  • Next message: Bernie Roehl: "Re: SFRotation to Matrix question"
  • Previous message: Bernie Roehl: ".dxf import problems"
  • Next in thesad: Bernie Roehl: "Re: SFRotation to Matrix question"