From 30ab57ee79c9ee9404cfd16e0fe8b0afd03161c5 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Tue, 19 Apr 2022 18:20:58 -0400 Subject: [PATCH] Found a problem with the calculation for the non-Euclidean grow/ shrink routine that over-computes the diagonal position (the equation failed to divide the intersecting angle in half). Rewrote the equation for the correct grow distance, still accounting for the grid limit (if set). --- VERSION | 2 +- cif/CIFgen.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index b6bee8d1..90204fc8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.291 +8.3.292 diff --git a/cif/CIFgen.c b/cif/CIFgen.c index ba6f8dd4..4141a7ca 100644 --- a/cif/CIFgen.c +++ b/cif/CIFgen.c @@ -585,7 +585,7 @@ cifGrowEuclideanFunc(tile, table) { int growDistanceX, growDistanceY; int height, width; - double hyp; + double frac, ratio; int limit; if (oldType & TT_SIDE) @@ -605,9 +605,13 @@ cifGrowEuclideanFunc(tile, table) width = area.r_xtop - area.r_xbot; height = area.r_ytop - area.r_ybot; - hyp = sqrt((double)(width * width + height * height)); - growDistanceY = ceil((double)(growDistance * width) / hyp); - growDistanceX = ceil((double)(growDistance * height) / hyp); + ratio = (double)height / (double)width; + frac = ratio / (1 + sqrt(1 + ratio * ratio)); + growDistanceX = ceil((double)growDistance * frac); + + ratio = (double)width / (double)height; + frac = ratio / (1 + sqrt(1 + ratio * ratio)); + growDistanceY = ceil((double)growDistance * frac); /* Adjust for grid limit */ growDistanceX = SetValueGrid(growDistanceX);