You are not logged in.
Pages: 1
Given a matrix where there is some varying number of columns and rows I need to calculate for any given 'tile' its ROW and COLUMN.
Example, a matrix that has 3 columns and 3 rows will have a total of 9 tiles and tile#4 will be in the 1st column, 2nd row, whereas if it were a 4X4 matrix tile#4 would be in the 4th column, first row.
So the knowns at any given time are tileNumber, numberOfRows, and numberOfColumns. From those variables I want a calculation for the associated column and row for any given TileNumber.
FYI The matrixes will all have equal col/row (3X3, 4X4, 5X5)
The needed formulas:
Column = SomeFormula(tileNumber,NumberofRows)
Row = SomeFormula(tileNumber,NumberofColumns)
*keep in mind numberOfRows and numberOfColumns will always be equal in this particular exercise.
Example 3X3 matrix with associated tileNumbers. So tileNumber 4 in this example has a row value of 2 and a column value of 1.
1 | 2 | 3
4 | 5 | 6
7 | 8 | 9
Offline
Hi rickg
The formulas are:
Column= TileNumber mod NumberofColumns
Row= TileNumber div NumberofColumns + 1
If you have any either questions, you're free to ask.
And welcome to the forum!
Last edited by anonimnystefy (2012-03-07 21:30:35)
Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.
Offline
I would rather say that
Row= TileNumber div NumberofColumns + 1
Offline
Yes you're right, forgot to add that.
Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.
Offline
Pages: 1