#include "Point.h" #include #include // for srand, rand class NumberGenerator { public: static std::list get_random_numbers(int valCount) { std::list points; //srand(static_cast (time(0))); srand(static_cast (0)); // fixed seed for testing float x = 0; float y = 0; for (int i = 0; i < valCount; ++i) { x = OFFSET + static_cast (rand()) / (static_cast (RAND_MAX / (WIDTH - 2*OFFSET))); y = OFFSET + static_cast (rand()) / (static_cast (RAND_MAX / (HEIGHT - 2*OFFSET))); points.push_back(Point(x, y)); } return points; } static std::list get_rectangle_numbers(int valCount) { std::list points; float diff = (2.f * HEIGHT/valCount); float x = 0; float y = 0; for (int i = 0; i < valCount; ++i) { x = (i%2 == 0) ? OFFSET : WIDTH - OFFSET; y = diff/2 + (i/2) * diff; points.push_back(Point(x, y)); } return points; } static std::list get_circle_numbers(int valCount) { std::list points; float rad = HEIGHT/2; float deg = (float)(2 * 3.14159 / valCount); float x = 0; float y = 0; for (int i = 0; i < valCount; ++i) { x = WIDTH/2 + rad * cosf(i * deg); y = HEIGHT/2 + rad * sinf(i * deg); points.push_back(Point(x, y)); } return points; } };