covid-sim
Loading...
Searching...
No Matches
Param.cpp
1#include "Param.h"
2
3int Param::get_number_of_micro_cells_wide() const {
4 return this->ncw * this->NMCL;
5}
6
7int Param::get_number_of_micro_cells_high() const {
8 return this->nch * this->NMCL;
9}
10
11MicroCellPosition Param::get_micro_cell_position_from_cell_index(int cell_index) const {
12 int x = cell_index / this->get_number_of_micro_cells_high();
13 int y = cell_index % this->get_number_of_micro_cells_high();
14 return {x, y};
15}
16
17bool Param::is_in_bounds(MicroCellPosition position) const {
18 return position.x >= 0
19 && position.y >= 0
20 && position.x < this->get_number_of_micro_cells_wide()
21 && position.y < this->get_number_of_micro_cells_high();
22}
23
24int Param::get_micro_cell_index_from_position(MicroCellPosition position) const {
25 int x = (position.x + this->get_number_of_micro_cells_wide()) % this->get_number_of_micro_cells_wide();
26 int y = (position.y + this->get_number_of_micro_cells_high()) % this->get_number_of_micro_cells_high();
27 return x * this->get_number_of_micro_cells_high() + y;
28}