2D to 1D Array

 

-2D(Width, Height) to 1D Array Formula = Y * Width + X

-Example of a 2D array with size:
Width = 20, Height = 50
-Example position(X, Y) in this array:
X = 15
Y = 35

-Representing this 2D position by a 1D Array:
–> Y * Width + X
–> 35 * 20 + 15
–> 715

Updated: —

Leave a Reply

Your email address will not be published. Required fields are marked *