Please do not reply to this email: if you want to comment on the bug, go to    
       
the URL shown below and enter yourcomments there.     
   
https://bugs.freedesktop.org/show_bug.cgi?id=6748          
     
           Summary: __gluInvertMatrixd:This function has error
           Product: Mesa
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P3
         Component: GLU
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


$(mesasrc)/glu/sgi/libutil/project.c:__gluInvertMatrixd:This algorithm is wrong

The inverse matrix of identity matrix is itself!

but old __gluInvertMatrixd consider identity matrix is bad matrix.

modified:

/*
** inverse = invert(src)
*/
static int __gluInvertMatrixd(const GLdouble src[16], GLdouble inverse[16])
{
    int i, j, k;
    double t;
    GLdouble temp[4][4];

    for (i=0; i<4; i++) {
        for (j=0; j<4; j++) {
            temp[i][j] = src[i*4+j];
        }
    }
    __gluMakeIdentityd(inverse);

    for (i = 0; i < 4; i++) {
        if (temp[i][i] == 0.0f) {
            /*
            ** Look for non-zero element in column
            */
            for (j = i + 1; j < 4; j++) {
                if (temp[j][i] != 0.0f) {
                    break
                }
            }
        
            if (j != 4) {
                /*
                 ** Swap rows.
                 */
                for (k = 0; k < 4; k++) {
                    t = temp[i][k];
                    temp[i][k] = temp[j][k];
                    temp[j][k] = t;
        
                    t = inverse[i*4+k];
                    inverse[i*4+k] = inverse[j*4+k];
                    inverse[j*4+k] = t;
                }
            }
            else {
                /*
                ** No non-zero pivot.  The matrix is singular, which shouldn't
                ** happen.  This means the user gave us a bad matrix.
                */
                return GL_FALSE;
            }
        }

        t = 1.0f / temp[i][i];
        for (k = 0; k < 4; k++) {
            temp[i][k] *= t;
            inverse[i*4+k] *= t;
        }
        for (j = 0; j < 4; j++) {
            if (j != i) {
                t = temp[j][i];
                for (k = 0; k < 4; k++) {
                    temp[j][k] -= temp[i][k]*t;
                    inverse[j*4+k] -= inverse[i*4+k]*t;
                }
            }
        }
    }
    return GL_TRUE;
}          
     
     
--           
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email         
     
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to