Eigen::MatrixXi IsometricGridDot::makeIsometricPattern()

in IsometricPatternMatcher/IsometricPattern.cpp [14:38]


Eigen::MatrixXi IsometricGridDot::makeIsometricPattern(uint32_t seed) {
  Eigen::MatrixXi M(storageMapRows_, storageMapRows_);
  std::mt19937 rng(seed);

  std::uniform_int_distribution<uint32_t> uintDist1(0, 1);

  for (int r = 0; r < M.rows(); ++r) {
    int row = r - numberLayer_;
    for (int q = 0; q < M.cols(); ++q) {
      int col =
          q - numberLayer_ + (r - numberLayer_ - ((r - numberLayer_) & 1)) / 2;

      M(r, q) =
          (r + q < numberLayer_ ||
           r + q >
               3 * numberLayer_ ||  // upper and lower triangles of the matrix
           abs(row) > gridRowsCols_[0] / 2 ||
           abs(col) > gridRowsCols_[1] /
                          2)  // outside the specified rows and cols of the grid
              ? 2
              : uintDist1(rng);
    }  // upper and lower triangles of the matrix should be Null, incidated by 2
  }
  return M;
}