From a55127dbe7d5557eeb019e1ed50fae16f84c2547 Mon Sep 17 00:00:00 2001 From: Erwin Janssen Date: Thu, 3 Nov 2016 01:18:20 +0100 Subject: [PATCH] Fix: shape coordinates close to 0 now absolutely 0 Check wether the values are close to zero by checking if it lies between -0.00001 and 0.00001. If this is the case, set the value to 0. This prevents coordinates like 7.10543e-15, that are differ by platform. --- lib/common/shapes.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/common/shapes.c b/lib/common/shapes.c index 61e4fe196..733ccb42d 100644 --- a/lib/common/shapes.c +++ b/lib/common/shapes.c @@ -2888,7 +2888,18 @@ static void poly_gencode(GVJ_t * job, node_t * n) for (i = 0; i < sides; i++) { P = vertices[i + j * sides]; AF[i].x = P.x * xsize + ND_coord(n).x; - AF[i].y = P.y * ysize + ND_coord(n).y; + AF[i].y = P.y * ysize + ND_coord(n).y; + + // Set values that are close to zero, to absolute zero. + // This prevents coördinates like 7.10543e-15 + if (AF[i].x > -0.00001 && AF[i].x < 0.00001) + { + AF[i].x = 0; + } + if (AF[i].y > -0.00001 && AF[i].y < 0.00001) + { + AF[i].y = 0; + } } if (sides <= 2) { if ((style & WEDGED) && (j == 0) && multicolor(fillcolor)) { -- 2.40.0