added rng mode for diagonals

This commit is contained in:
incredibleLeitman 2020-11-30 18:25:18 +01:00
parent f65041c0ad
commit 872cd6c452

View File

@ -2,6 +2,7 @@
#include <cstdlib> // for srand, rand
#include <fstream> // ifstream
#include <ctime> // time
#include <algorithm>
class NumberGenerator
{
@ -20,6 +21,10 @@ public:
{
return NumberGenerator::get_circle_numbers(count);
}
else if (mode == 4)
{
return NumberGenerator::get_diagonal_numbers(count);
}
else throw "unspecified rng Mode"; // TODO: could handle in parse args
}
@ -114,4 +119,19 @@ public:
}
return points;
}
static std::list<Point> get_diagonal_numbers(const int valCount)
{
std::list<Point> points;
float x = 0;
float y = 0;
for (int i = 0; i < valCount; ++i)
{
x = OFFSET + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / (std::min(WIDTH, HEIGHT) - 2 * OFFSET)));
points.push_back(Point(x, HEIGHT - x)); // /
//points.push_back(Point(x, HEIGHT - x)); // \
}
return points;
}
};