The XYMatrix example is a great start for using matrixes and we use this

The XYMatrix example is a great start for using matrixes and we use this principle a lot. But sometimes you would like to flip a matrix horizontally or vertically.

Does anybody has some spare code laying around to achieve this? Best would be without duplicate arrays but a straight honest and simple function. Maybe somebody already modified the XY function for this purpose?

I just started playing with a matrix and this would be useful to know.

I don’t have anything already, but if you post a diagram of your layout, I’d be happy to help you come up with the code to map from XY to index.

As I understand you want to transpose a matrix (x,y), I’m afraid it is hard to do it in place (without creating second matrix) when x!=y. It should be possible to do it using dynamic allocation, however there would be a lot of data coping not sure if it is worth it. But I could be missing some ideas :slight_smile:

If you dont want to do it on the fly(dynamicly) all you have to do is flip your xy map. Use excel!

The aim is to do it dynamically and no second matrix since there is simply no memory for this. And then have a variable just like serpentine. Something like flipvertical, fliphorizontal. @Leon_Yuhanov no excel :wink:

@Jonas_Vorwerk So dynamic flips are pretty easy, you only need 1 array to hold either the VER or HOR stripe of pixels. you then swap the with a for loop. Rotation is harder…not sure of a simple algorithmic approach