Posted By

helloworlder on 08/03/09


array coordinates 2d 1D

Versions (?)

2D array to 1D array conversion

 / Published in: Pseudocode

Convert a coordinate (x,y) into the index for a 1D array. For example, the coordinate (3,1) would be at array index 8 if there are 5 columns.

Assumption: Arrays start at 0.

  1. arrayPosition = (y * numberOfColumns) + x

Report this snippet  

You need to login to post a comment.