ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Row major means that all your data depend on the width
.
When parsing the data (an array), you start at index 0
, when index = width - 1
then you have parsed through all the first row. So when index
is in [0, width - 1]
: row = 0
and column = index
.
Now if you are in the second row then index
will be in [width, 2*width - 1]
: row = 1
and column = index - width
For third row index is between [2*width, 3*width-1]
: row = 2
and column = index - 2*width
We see a pattern here and we can deduce the formula for row and column. The column is always the rest of index minus a multiple of the width, hence a modulo so column = index % width
. Now this multiple corresponds to the row so row = (index - index % width)/width