Looking at the original code, it does not appear to be the intention to check for true matrix orthogonality, but only to check the upper 3x3 matrix. Although it still does not check the normality condition of columns. Whether this is the intention, or an error I'm not sure. Would be useful to see what the original intention was by looking at uses and talk to the author if possible.
Thanks, Andrew On Fri, Jan 27, 2012 at 1:45 PM, Andrew Hale <[email protected]>wrote: > Hi Campbell, > > This fix adds the condition that the columns be unit length which is a > requirement of orthogonal matrices [1]. > > From Python you can check this with the code here [2]. This matrix is not > orthogonal, even though its columns are. For another example of a matrix > which has orthogonal columns but the matrix is not orthogonal, see here [3]. > > If the intention of the function is to check for true matrix orthogonality > then this change is consistent. > > Cheers, > Andrew > > PS That 1 in the final "if" should be 1.0f shouldn't it? > > [1] http://mathworld.wolfram.com/OrthogonalMatrix.html > [2] http://www.pasteall.org/28577/python > [3] http://en.wikipedia.org/wiki/Orthogonal_matrix#Properties > > > On Fri, Jan 27, 2012 at 4:23 AM, Campbell Barton <[email protected]>wrote: > >> Can you give an example as to what case this fixes? >> >> On Fri, Jan 27, 2012 at 4:11 AM, Sv. Lockal <[email protected]> wrote: >> > Revision: 43733 >> > >> http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43733 >> > Author: lockal >> > Date: 2012-01-26 17:11:43 +0000 (Thu, 26 Jan 2012) >> > Log Message: >> > ----------- >> > Fix orthogonality check for mat3 and mat4 >> > >> > Modified Paths: >> > -------------- >> > trunk/blender/source/blender/blenlib/intern/math_matrix.c >> > >> > Modified: trunk/blender/source/blender/blenlib/intern/math_matrix.c >> > =================================================================== >> > --- trunk/blender/source/blender/blenlib/intern/math_matrix.c 2012-01-26 >> 17:03:30 UTC (rev 43732) >> > +++ trunk/blender/source/blender/blenlib/intern/math_matrix.c 2012-01-26 >> 17:11:43 UTC (rev 43733) >> > @@ -778,32 +778,38 @@ >> > mul_v3_fl(mat[2], size[2]); >> > } >> > >> > -int is_orthogonal_m3(float mat[][3]) >> > +int is_orthogonal_m3(float m[][3]) >> > { >> > - if (fabsf(dot_v3v3(mat[0], mat[1])) > 1.5f * FLT_EPSILON) >> > - return 0; >> > + int i, j; >> > >> > - if (fabsf(dot_v3v3(mat[1], mat[2])) > 1.5f * FLT_EPSILON) >> > - return 0; >> > + for (i = 0; i < 3; i++) { >> > + for (j = 0; j < i; j++) { >> > + if (fabsf(dot_v3v3(m[i], m[j])) > 1.5f * FLT_EPSILON) >> > + return 0; >> > + } >> > >> > - if (fabsf(dot_v3v3(mat[0], mat[2])) > 1.5f * FLT_EPSILON) >> > - return 0; >> > - >> > - return 1; >> > + if (fabsf(dot_v3v3(m[i], m[i]) - 1) > 1.5f * FLT_EPSILON) >> > + return 0; >> > + } >> > + >> > + return 1; >> > } >> > >> > -int is_orthogonal_m4(float mat[][4]) >> > +int is_orthogonal_m4(float m[][4]) >> > { >> > - if (fabsf(dot_v3v3(mat[0], mat[1])) > 1.5f * FLT_EPSILON) >> > - return 0; >> > + int i, j; >> > >> > - if (fabsf(dot_v3v3(mat[1], mat[2])) > 1.5f * FLT_EPSILON) >> > - return 0; >> > + for (i = 0; i < 4; i++) { >> > + for (j = 0; j < i; j++) { >> > + if (fabsf(dot_vn_vn(m[i], m[j], 4)) > 1.5f * FLT_EPSILON) >> > + return 0; >> > + } >> > >> > - if (fabsf(dot_v3v3(mat[0], mat[2])) > 1.5f * FLT_EPSILON) >> > - return 0; >> > - >> > - return 1; >> > + if (fabsf(dot_vn_vn(m[i], m[i], 4) - 1) > 1.5f * FLT_EPSILON) >> > + return 0; >> > + } >> > + >> > + return 1; >> > } >> > >> > void normalize_m3(float mat[][3]) >> > >> > _______________________________________________ >> > Bf-blender-cvs mailing list >> > [email protected] >> > http://lists.blender.org/mailman/listinfo/bf-blender-cvs >> >> >> >> -- >> - Campbell >> _______________________________________________ >> Bf-committers mailing list >> [email protected] >> http://lists.blender.org/mailman/listinfo/bf-committers >> > > _______________________________________________ Bf-committers mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-committers
