Here's the source code. ANSWER
is the correct answer, RESULT
is the actual result.
Am I blind, or is it calculating a -1
for entry 33
when it should be a 1
?
Here's the code:
GLKMatrix4 a = GLKMatrix4Make(-1.000000, 0.000000, 0.000000, 0.000000,
0.000000, 1.000000, 0.000000, 0.000000,
0.000000, 0.000000, -1.000000, 0.000000,
0.000000, 0.000000, 0.000000, 1.000000);
GLKMatrix4 b = GLKMatrix4Make(1.000000, 0.000000, 0.000000, 0.000000,
0.000000, 1.000000, 0.000000, -1.000000,
0.000000, 0.000000, 1.000000, -1.000000,
0.000000, 0.000000, 0.000000, 1.000000);
GLKMatrix4 ANSWER = GLKMatrix4Make(-1.000000, 0.000000, 0.000000, 0.000000,
0.000000, 1.000000, 0.000000, -1.000000,
0.000000, 0.000000, -1.000000, 1.000000,
0.000000, 0.000000, 0.000000, 1.000000);
NSLog(@"##################################################");
GLKMatrix4 RESULT = GLKMatrix4Multiply(a,b);
NSLog(@"Result:");
NSLog(@" %f %f %f %f",RESULT.m00,RESULT.m01,RESULT.m02,RESULT.m03);
NSLog(@" %f %f %f %f",RESULT.m10,RESULT.m11,RESULT.m12,RESULT.m13);
NSLog(@" %f %f %f %f",RESULT.m20,RESULT.m21,RESULT.m22,RESULT.m23);
NSLog(@" %f %f %f %f",RESULT.m30,RESULT.m31,RESULT.m32,RESULT.m33);
NSLog(@"Answer:");
NSLog(@" %f %f %f %f",ANSWER.m00,ANSWER.m01,ANSWER.m02,ANSWER.m03);
NSLog(@" %f %f %f %f",ANSWER.m10,ANSWER.m11,ANSWER.m12,ANSWER.m13);
NSLog(@" %f %f %f %f",ANSWER.m20,ANSWER.m21,ANSWER.m22,ANSWER.m23);
NSLog(@" %f %f %f %f",ANSWER.m30,ANSWER.m31,ANSWER.m32,ANSWER.m33);
NSLog(@"##################################################");
Here's the output:
##################################################
Result:
-1.000000 0.000000 0.000000 0.000000
0.000000 1.000000 0.000000 -1.000000
0.000000 0.000000 -1.000000 -1.000000
0.000000 0.000000 0.000000 1.000000
Answer:
-1.000000 0.000000 0.000000 0.000000
0.000000 1.000000 0.000000 -1.000000
0.000000 0.000000 -1.000000 1.000000
0.000000 0.000000 0.000000 1.000000
##################################################
I've spent the last 5 hours trying to debug some OpenGL code only to find this is the problem. I must be missing something, surely. Can anyone spot what's going on, or verify this shouldn't be happening?