From eece03d24f690cb7cefbba32f4db304036843f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zieli=C5=84ski?= Date: Wed, 8 May 2024 13:16:26 +0200 Subject: [PATCH] Fix for centering the tiles, extra logs --- lib/rmg/PenroseTiling.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/rmg/PenroseTiling.cpp b/lib/rmg/PenroseTiling.cpp index 644ae6078..b5568a225 100644 --- a/lib/rmg/PenroseTiling.cpp +++ b/lib/rmg/PenroseTiling.cpp @@ -173,21 +173,30 @@ std::set PenroseTiling::generatePenroseTiling(size_t numZones, CRandomG split(t, points, indices, DEPTH); } - // Find center of the mass, shift that center to (0.5, 0.5) + std::set uniquePoints(points.begin(), points.end()); + std::vector uniquePointsVec(uniquePoints.begin(), uniquePoints.end()); + logGlobal->info("Generated %d vertices and %d unique vertices", points.size(), uniquePointsVec.size()); + + // Find center of the mass, shift that center to (0.5, 0.5) Point2D center = Point2D(0.0f, 0.0f); - for (auto & point : points) + for (const auto & point : uniquePointsVec) { center = center + point; }; - center = center / points.size(); + center = center / uniquePointsVec.size(); - for (auto & point : points) + // This center is very close to (0.0, 0.0), anyway + logGlobal->info("Penrose tiling center: %s", center.toString().c_str()); + + for (auto & point : uniquePointsVec) { point = point - center + Point2D(0.5f, 0.5f); }; - vstd::copy_if(points, vstd::set_inserter(finalPoints), [](const Point2D point) + // For 8X8 map, only 650 out of 15971 points are in the range + + vstd::copy_if(uniquePointsVec, vstd::set_inserter(finalPoints), [](const Point2D point) { return vstd::isbetween(point.x(), 0.f, 1.0f) && vstd::isbetween(point.y(), 0.f, 1.0f); });