I just recently got into matrix calculation, so might be that i got the whole system sorta wrong, but lets try. I want to create a transformation matrix which includes a translation and a scale. I start with an identity Matrix and then apply these transformations one after the other. Do i have to use “scaleMat” or “setScaleMat” for the scale then? Maybe i have a wrong understanding of these commands, but both pretty much overwrite the matrix with a new matrix which implements only the scale:
>>> myMatrix=Mat4()
>>> myMatrix
Mat4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
>>> myMatrix.setTranslateMat(Vec3(2.0,3.0,4.0))
>>> myMatrix
Mat4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2, 3, 4, 1)
>>> myMatrix.setScaleMat(Vec3(2.0,2.0,2.0))
>>> myMatrix
Mat4(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1)
…does pretty much the same as…
>>> myMatrix=Mat4()
>>> myMatrix
Mat4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
>>> myMatrix.translateMat(Vec3(2.0,3.0,4.0))
Mat4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2, 3, 4, 1)
>>> myMatrix.scaleMat(Vec3(2.0,2.0,2.0))
Mat4(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1)
In both variations the translation gets overwritten by the scale… At the moment i am implementing it by creating two seperate matrices and multiplying them into one. It works, but it feels like a workaround for an issue, or am i wrong? I mean, why are there two different commands, that always come up with the same result?
Just as reference, i checked it back with CGKit’s way and there the calculation turnes out like i expected it:
>>> myMatrix=mat4(1.0)
>>> myMatrix.translate(vec3(2.0,3.0,4.0))
[1, 0, 0, 2]
[0, 1, 0, 3]
[0, 0, 1, 4]
[0, 0, 0, 1]
>>> myMatrix.scale(vec3(2.0,2.0,2.0))
[2, 0, 0, 2]
[0, 2, 0, 3]
[0, 0, 2, 4]
[0, 0, 0, 1]
Here the translation part is still there. Is this valid?