- Home /
Matrix4x4 getcolumn/row doesn't match it's own float array
I have an issue where the GetColumn and GetRow and even printing the matrix itself doesn't return the data that's in it's float array.
The float array is this:
0.9999999,0,0,4.00131E-07,0,0.9999999,0,0,0,0,0.9999999,0,0,0,0,1
And the matrix/getcolumn/getrow all display data from this data set:
1.00000 0.00000 0.00000 0.00000
0.00000 1.00000 0.00000 0.00000
0.00000 0.00000 1.00000 0.00000
0.00000 0.00000 0.00000 1.00000
Here's my code:
string f = "";
Matrix4x4 m4 = new Matrix4x4();
for (int i = 0; i < 16; i++){
m4[i] = bindShapeMatrix[i]; //bindShapeMatrix[i] is a float
f += "," + m4[i];
}
Debug.Log("m4:" + m4);//this returns data I didn't put in the matrix
Debug.Log("m4c:" + m4.GetColumn(0));//this returns data I didn't put in the matrix
Debug.Log("m4r:" + m4.GetRow(0)); //this returns data I didn't put in the matrix
Debug.Log("floats:" + f); //This is what I should have stored in the matrix
Any idea's what I'm missing out on?
Answer by krdluzni · Aug 26, 2011 at 09:37 PM
All of the 0.9999999 values will round to 1.00000. Count the number of digits, and this will be clear (7 for the first, 5 for the second). Then the 4.00131E-07 is a very small value that will round to 0. It's actually 0.000000400131 (go here to learn about Scientific Notation: http://en.wikipedia.org/wiki/Scientificnotation#Enotation ). If what you want is for it to display the full value, you'll have to use custom formatting, but if it's just debug information, I wouldn't waste the effort.