Beispiel #1
0
/*
 *  Set up transform
 *     Push and apply transformation
 *     Calculate light position in local coordinate system (Lp)
 *     Calculate clipping plane in local coordinate system (Ec,Nc)
 *  Global variables set: Lp,Nc,Ec
 *  Killer fact 1:  You MUST call this to set transforms for objects
 *  Killer fact 2:  You MUST call glPopMatrix to undo the transform
 */
void Transform(float x0,float y0,float z0,
               float Sx,float Sy,float Sz,
               float th,float ph)
{
   double M[16]; // Transformation matrix
   int    I[4];  // Pivot
   double Z;     // Location of clip plane

   //  Save current matrix
   glPushMatrix();

   //  Build transformation matrix and copy into M
   glPushMatrix();
   glLoadIdentity();
   glTranslated(x0,y0,z0);
   glRotated(ph,1,0,0);
   glRotated(th,0,1,0);
   glScaled(Sx,Sy,Sz);
   glGetDoublev(GL_MODELVIEW_MATRIX,M);
   glPopMatrix();

   //  Apply M to existing transformations
   glMultMatrixd(M);

   /*
    *  Determine light position in this coordinate system
    */
   Crout(M,I);
   Lp = Backsolve(M,I,Lpos[0],Lpos[1],Lpos[2],Lpos[3]);

   /*
    *  Determine clipping plane E & N
    *  Use the entire MODELVIEW matrix here
    */
   glGetDoublev(GL_MODELVIEW_MATRIX,M);
   //  Normal is down the Z axis (0,0,1) since +/- doesn't matter here
   //  The normal matrix is the inverse of the transpose of M
   Nc.x = M(2,0);
   Nc.y = M(2,1);
   Nc.z = M(2,2);
   //  Far  clipping plane for Z-fail should be just less than 8*dim
   //  Near clipping plane for Z-pass should be just more than dim/8
   Crout(M,I);
   Z = (mode==5) ? -7.9*dim : -0.13*dim;
   Ec = Backsolve(M,I,0,0,Z,1);
}
ESymSolverStatus
Ma57TSolverInterface::MultiSolve(bool         new_matrix,
                                 const Index*     airn,
                                 const Index*     ajcn,
                                 Index        nrhs,
                                 double*      rhs_vals,
                                 bool         check_NegEVals,
                                 Index        numberOfNegEVals)
{
    DBG_START_METH("Ma57TSolverInterface::MultiSolve",dbg_verbosity);

    // DBG_ASSERT(!check_NegEVals || ProvidesInertia());
    // DBG_ASSERT(initialized_);
    // DBG_ASSERT(la_!=0);

    if (pivtol_changed_) {
        DBG_PRINT((1,"Pivot tolerance has changed.\n"));
        pivtol_changed_ = false;
        // If the pivot tolerance has been changed but the matrix is not
        // new, we have to request the values for the matrix again to do
        // the factorization again.
        if (!new_matrix) {
            DBG_PRINT((1,"Ask caller to call again.\n"));
            refactorize_ = true;
            return SYMSOLVER_CALL_AGAIN;
        }
    }

    // check if a factorization has to be done
    DBG_PRINT((1, "new_matrix = %d\n", new_matrix));
    if (new_matrix || refactorize_) {
        // perform the factorization
        ESymSolverStatus retval;
        retval = Factorization(airn, ajcn, check_NegEVals, numberOfNegEVals);
        if (retval!=SYMSOLVER_SUCCESS) {
            DBG_PRINT((1, "FACTORIZATION FAILED!\n"));
            return retval;  // Matrix singular or error occurred
        }
        refactorize_ = false;
    }

    // do the backsolve
    return Backsolve(nrhs, rhs_vals);
}