Esempio n. 1
0
Wtransf
compute_xf(CARRAY<Wvec>& v)
{
   WMat3 A;

   // build the symmetric matrix:
   double s = 0;
   for (int i=0; i<3; i++) {
      for (int j=i; j<3; j++) {
         A[i][j] = A[j][i] = cross_mult(i,j,v);
         s = max(s, fabs(A[i][j]));
      }
   }
   // divide by largest value:
   if (s > 1e-5)
      A = A/s;

   cerr << "A: "
        << endl
        << A
        << endl;

   WMat3 V = sym_mat_eigenvectors(A);

   // this just handles the rotation...
   return Wtransf(V.row(0),V.row(1),V.row(2)).transpose();
}
Esempio n. 2
0
void 
SKY_BOX::update_position() //centers the sky box around the camera
{
   Wpt eye = VIEW::eye();
   if (eye.dist_sqrd(xform().origin()) > 0) { //only update when really needed
      set_xform(Wtransf(eye));
      err_adv(debug, "SKY_BOX::update_position: updated skybox");
   }
}