From 0d4172901bb0f9a37c46cd46da786cf92155774c Mon Sep 17 00:00:00 2001 From: jaseg Date: Thu, 30 Mar 2023 15:05:09 +0200 Subject: Fix scale of drill mapping test --- svg-flatten/src/svg_doc.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'svg-flatten/src') diff --git a/svg-flatten/src/svg_doc.cpp b/svg-flatten/src/svg_doc.cpp index 77b561e..afb3a68 100644 --- a/svg-flatten/src/svg_doc.cpp +++ b/svg-flatten/src/svg_doc.cpp @@ -298,10 +298,12 @@ void gerbolyze::SVGDocument::export_svg_path(RenderContext &ctx, const pugi::xml d2p centroid = nopencv::polygon_centroid(geom_poly); centroid[0] /= clipper_scale; centroid[1] /= clipper_scale; + /* area of n-gon with circumradius 1 relative to circle with radius 1 */ - double ngon_area_relative = p.size()/(2*std::numbers::pi) * sin(2*std::numbers::pi / p.size()); - double diameter = sqrt(4*fabs(area)/std::numbers::pi) / clipper_scale / ngon_area_relative; - double tolerance = ctx.settings().geometric_tolerance_mm / 2; + //double ngon_area_relative = p.size()/(2*std::numbers::pi) * sin(2*std::numbers::pi / p.size()); + // ^- correction not necessary, we already do a very good job. + double diameter = sqrt(4*fabs(area)/std::numbers::pi) / clipper_scale; + double tolerance = ctx.settings().geometric_tolerance_mm; diameter = round(diameter/tolerance) * tolerance; ctx.sink() << ApertureToken(diameter) << FlashToken(centroid); } -- cgit