x y z y z x z x y w = 120, h = 24 w = 40, h = 40 w = 240, h = 10 w = 10, h = 50
0000
0044

matrix world 2d

07 Jul 2021 • viridi | History | Comment

World matrix $\bf W$ represents the discretized two-dimensional spatial space. It is adapted from previous work [1].

concept

  1. There is a world $\bf W$ in the form of $N_y \times N_x$ matrix, where $N_y$ and $N_x$ are number of rows and columns, respectively.
  2. The world matrix $\bf W$ discretizes the continue two-dimensional spatial place with $L_x \times L_y$ grids through the relation $L_x = N_x \Delta x$ and $L_y = N_y \Delta y$, where it might be that $\Delta x = \Delta y$.
  3. As a matrix it begins at the left upper right cornet for element $w_{11}$, then followed by element $w_{1N_x}$ at the upper right corner and element $w_{N_y1}$ at the lower left corner, and finished by element $w_{N_yN_x}$ at the lower right corner.
  4. There is relation between matrix indices with real coordinates ($y$ ⌊_ $x$) in the form of $x = (i - \frac12) \Delta x$ and $y = (N_y - j + \frac12) \Delta y$, so that real coordinates $(x, y)$ can be represented by grid indices $(i, j)$.
  5. Inverse of the previous relations are $i = \lceil x / \Delta x \rceil$ and $i = N_y - \lceil y / \Delta y \rceil + 1$.
  6. Initially $w_{ij} = 0$ for $i = 1, \ .., N_x$ and $j = 1, \ .., N_y$.

implementation

Previous concept can be implemented in x as follows.

notes

  1. S. Viridi, F. Haryanto, “Agent-based Model and its Potential in Simulating Some Physical Systems”, IOP Conference Series: Materials Science and Engineering 559 (1), 012008 (2019), url https://doi.org/10.1088/1757-899X/599/1/012008.