Hi guys, I'm looking some help with finding an equation to represent the transform I require for a program I'm making. Unfortunately I'm not Mathematician, in-fact this may even be in the wrong section, my math knowlefge is that bad.

Essentially I have a Mesh of, in my case, Pixels (computer graphics ones) and I want to transform certain pixels in this mesh in a fairly simple fashion.

The process is iterative and that's the part that is causing me problems with determining a nice equation to do this with. I will try to explain as best I can so maybe you can understand what I'm trying to do first.

My "mesh" is 20x20. I want to iteratively "fold" the top right corner in, diagonally across the page until the top right corner meets the bottom left corner.

The coordinate system I'm using has x=y=0 at the top left of the grid.

So, if the top right "pixel" is 20, I need to translate that x-1, y+1, (left 1 pixel, down 1 pixel) essentially replacing the pixel at that position, then I need to take the top right 3 pixels (L shape), then 6 pixels, then 10 pixels, then 15 pixels, 21 ... (all traingles from the top right corner becoming increasingly larger until I reach half way.)

That's the first problem: Once that is sorted we can move on to part 2 (which is that the iterative process iterates through the pixels along the rows then down. (like a line feed and carriage return).

If my description wasn't very clear I can scan a drawing I have done of the process I'm looking to create.

Thanks.