I noticed in a swift playground (xcode 9) that it seems SCNMatrix4Mult returns a different result to matrix_multiply
I set up two matrices
- a translation of 5 along the x axis
- and a scale of 2 along all axis
Multiplying using SCNMatrix4Mult(position, translation) gave a 10 in the x axis position (as if it had done the position and then the scale) but i expected x 5 as it's non commutative and the apple docs say translation should be applied first being the second parameter.
Using the simd matrix_multiply in the same way, I got the x axis position as 5 as expected.
Am i doing something incorrect here?
var posMatrix = SCNMatrix4MakeTranslation(5,0,0)
var scaleMatrix = SCNMatrix4MakeScale(2,2,2)
var resultMatrix = SCNMatrix4Mult(posMatrix, scaleMatrix)
var simPosMatrix = matrix_identity_float4x4
simPosMatrix.columns.3.x = 5
var simScaleMatrix = matrix_identity_float4x4
simScaleMatrix.columns.0.x = 2
simScaleMatrix.columns.1.y = 2
simScaleMatrix.columns.2.z = 2
var simResultMatrix = matrix_multiply(simPosMatrix, simScaleMatrix)