LCOV - code coverage report
Current view: top level - cell - MathUtils.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 12 13 92.3 %
Date: 2025-12-26 22:55:38 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "MathUtils.hpp"
       2             : 
       3             : #include <algorithm>
       4             : #include <cmath>
       5             : #include <numbers>
       6             : #include <numeric>
       7             : #include <ostream>
       8             : #include <random>
       9             : 
      10             : namespace cell::mathutils
      11             : {
      12             : 
      13           3 : std::vector<Vector2d> calculateGrid(double width, double height, double edgeLength)
      14             : {
      15           3 :     static std::random_device rd;
      16           3 :     static std::mt19937 gen(rd());
      17             : 
      18           3 :     std::vector<Vector2d> gridPoints;
      19           3 :     gridPoints.reserve(static_cast<std::size_t>((static_cast<double>(width) / edgeLength) *
      20           3 :                                                 (static_cast<double>(height) / edgeLength)));
      21           3 :     double spacing = edgeLength + 1;
      22             : 
      23         835 :     for (int i = 0; i < static_cast<int>(width / spacing); ++i)
      24             :     {
      25      463166 :         for (int j = 0; j < static_cast<int>(height / spacing); ++j)
      26      462334 :             gridPoints.emplace_back(spacing * static_cast<double>(i + 1), spacing * static_cast<double>(j + 1));
      27             :     }
      28             : 
      29           3 :     std::shuffle(gridPoints.begin(), gridPoints.end(), gen);
      30             : 
      31           3 :     return gridPoints;
      32           0 : }
      33             : 
      34             : } // namespace cell::mathutils

Generated by: LCOV version 1.14