Bug 6749 - __gluInvertMatrixd:This function has error
__gluInvertMatrixd:This function has error
 Status: RESOLVED DUPLICATE of bug 6748 None Mesa Unclassified GLU (show other bugs) unspecified x86 (IA32) Windows (All) medium normal mesa-dev

 Reported: 2006-04-26 13:00 UTC by shan hao bo 2006-04-25 23:17 UTC (History) 0 users

Attachments

 shan hao bo 2006-04-26 13:00:05 UTC ```\$(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; }``` Michel Dänzer 2006-04-26 16:17:16 UTC ``` *** This bug has been marked as a duplicate of 6748 ***```

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.