I was trying to find information about transforming an index that has been converted from a 2 dimensional index , to a single one. Then turn the single index back to a 2 dimensional one. I don't even know what this method is called.
formula to single index
int index = x + y * width;
MyArray[index] ;
So my question is how do I turn it back into two dimensions?
int x = index ??? width;
int y = index ??? width;
Can't wrap my head around it for some reason.
Thanks
int x = index % width;
int y = index / width;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With