diff --git a/NumberGenerator.h b/NumberGenerator.h new file mode 100644 index 0000000..1628dc5 --- /dev/null +++ b/NumberGenerator.h @@ -0,0 +1,72 @@ +#include "Point.h" + +#include +#include // for srand, rand + +class NumberGenerator +{ +private: + static const int OFFSET = 0; + static const int WIDTH = 700; + static const int HEIGHT = 700; + +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; //8.0f; + 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; + } +}; \ No newline at end of file