/** * @brief * * @param radius * @param squared_radius * * @return */ bool IsRandomInside(int32_t radius, uint64_t squared_radius) { int32_t x, y; //std::random_device rd; std::mt19937 gen;//(rd()); std::uniform_int_distribution<int32_t> dist(-radius, radius); x = dist(gen); y = dist(gen); //std::cerr << x << "," << y << std::endl; return IsInsideCircle(squared_radius, x, y); }
extern "C" CPPLIB_API void DrawCircle(int bitmapArray[], int rowCount, int columnCount, int color, Vertex center, int radius) { int index; int radiusSqr = radius*radius; int minY = center.Y - radius; int maxY = center.Y + radius; int endY = maxY < rowCount ? maxY : rowCount; int startY = minY > 0 ? minY : 0; for (int y = startY; y < endY; y++) { for (int x = 0; x < radius; x++) { if (IsInsideCircle(center.X, center.Y, radiusSqr, center.X + x, y)) { int right = center.X + x; int left = center.X - x; if (left >= columnCount) { continue; } if (right < 0) { continue; } if (right < columnCount) { index = y * columnCount + right; bitmapArray[index] = color; } if (left >= 0) { index = y * columnCount + left; bitmapArray[index] = color; } } } } }
bool Knowledge::IsInsideSecureArea(Vector2D pos, Vector2D ball) { return IsInsideCircle(pos,ball,ALLOW_NEAR_BALL_RANGE); }