void urot_about_axis_f (float m[4][4], /* returned */ float angle, /* input */ float axis[3]) /* input */ #endif { gutDouble len, ax[3]; angle *= M_PI/180.0; /* convert to radians */ /* renormalize axis vector, if needed */ len = axis[0]*axis[0] + axis[1]*axis[1] + axis[2]*axis[2]; /* we can save some machine instructions by normalizing only * if needed. The compiler should be able to schedule in the * if test "for free". */ if (len != 1.0) { len = (gutDouble) (1.0 / sqrt ((double) len)); ax[0] = axis[0] * len; ax[1] = axis[1] * len; ax[2] = axis[2] * len; #ifdef __GUTIL_DOUBLE urot_axis_d (m, angle, ax); #else urot_axis_f (m, angle, ax); #endif } else { #ifdef __GUTIL_DOUBLE urot_axis_d (m, angle, axis); #else urot_axis_f (m, angle, axis); #endif } }
void rot_axis_f (float omega, /* input */ float axis[3]) /* input */ { float m[4][4]; (void) urot_axis_f (m, omega, axis); MULTMATRIX_F (m); }
void urot_omega_f (float m[4][4], /* returned */ float axis[3]) /* input */ #endif { gutDouble len, ax[3]; /* normalize axis vector */ len = axis[0]*axis[0] + axis[1]*axis[1] + axis[2]*axis[2]; len = (gutDouble) (1.0 / sqrt ((double) len)); ax[0] = axis[0] * len; ax[1] = axis[1] * len; ax[2] = axis[2] * len; /* the amount of rotation is equal to the length, in radians */ #ifdef __GUTIL_DOUBLE urot_axis_d (m, len, ax); #else urot_axis_f (m, len, ax); #endif }