# Matrix4 multiplication problem

Recently I have noticed that the value returned by the gml math library, is different to that returned by OpenTK when I multiply matrices.

The image shows the two input matrices and the result matrix that matches the gml library. OpenTK returns the following array:

Row0 = 1.0; 0.0; 0.0; 0.0
Row1 = 0.0; 0.5; -0.866; 0.0
Row2 = 0.0; 0.866; 0.5; 0.0
Row3 = 0.0; -86.602; -50; 1.0

Can anyone verify this?

Inline Images

## Comment viewing options

### Re: Matrix4 multiplication problem

Site where I found a calculator matrix is this.

### Re: Matrix4 multiplication problem

Tested with OpenTK version 1.1.1428.49013

### Re: Matrix4 multiplication problem

I just tested an I am getting:

```a
(1; 0; 0; 0)
(0; 1; 0; 0)
(0; 0; 1; -100)
(0; 0; 0; 1)
b
(1; 0; 0; 0)
(0; 0,5; 0,866; 0)
(0; -0,866; 0,5; 0)
(0; 0; 0; 1)
c = a * b
(1; 0; 0; 0)
(0; 0,5; 0,866; 0)
(0; -0,866; 0,5; -100)
(0; 0; 0; 1)```

Are you using a specific Matrix4* class? Which method are you using for the multiplication?

Edit:
are you, by any chance, mixing a * b with b * a? The latter gives a result similar to the one you are getting.

### Re: Matrix4 multiplication problem

The problem is that I'm porting source code that was originally written to use the glm library, glm uses the OpenGL convention 'column-major' and OpenTK uses 'row-major'. I have to invert operations, for example:

Gml Code:
viewMatrix = translateMatrix * rotateMatrix * pivotMatrix

OpenTK code:
viewMatrix = pivotMatrix * rotateMatrix * translateMatrix