Translation_Matrix Question About Metal

Doctor Caroline:

      I have a new question about Chapter 4 -- Coordinate Spaces. If I wanna  operate the same translation(same translation matrix) many times only(without any scaling and rotation) , how I can complete it.
      I test translation_matrix. inverse * translation_matrix.inverse but can not get the function that I want.

I don’t understand what you mean. You can use the same translation matrix over and over. Why are you trying to multiply the matrix inverse by the matrix inverse? What are you trying to achieve?

Sorry, I mean I want to use the same translation matrix over and over at a time. But how Can I write the code? I try to write “matrix = translation * translation * translation” and try to write " matrix = translation * translation * translation.inverse", but the result is nothing.

How are you applying the matrix? Are you applying it to the vertices in a metal buffer as in the playground in Chapter 4?
Are you using a separate buffer for each draw call in the frame? (Otherwise you’ll be just overwriting the buffer each time - that’s why chapter 4 uses two different buffers in the playground)

If you’re having trouble with the inverse, you can do:

var matrix = matrix_identity_float4x4
matrix.columns.3.x = 0.3

That will translate the triangle 0.3 to the right.

Then matrix.inverse will have -0.3 in matrix.columns.3.x and you can translate it 0.3 to the left.

Try printing out the matrices using print to see what is in them.

Do you have experience of linear algebra or matrix multiplication?

Thank you Caroline. I have experience of advanced algebra. Maybe I understand fault way. I will try again.

@richmond_jam Do you still have issues with this?

I solved this problem.