From 10a07a82c3c0427feb0f51fd612a6a1dbdb81b2e Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sat, 7 Oct 2023 01:50:56 -0700 Subject: [PATCH] fix arclength calculations giving invalid values or non-integral steps --- masque/shapes/arc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/masque/shapes/arc.py b/masque/shapes/arc.py index c662175..2b7046a 100644 --- a/masque/shapes/arc.py +++ b/masque/shapes/arc.py @@ -218,11 +218,11 @@ class Arc(Shape): r1cos = r1 * numpy.cos(t) arc_dl = numpy.sqrt(r0sin * r0sin + r1cos * r1cos) #arc_lengths = numpy.diff(t) * (arc_dl[1:] + arc_dl[:-1]) / 2 - arc_lengths = (arc_dl[1:] + arc_dl[:-1]) * dt / 2 + arc_lengths = (arc_dl[1:] + arc_dl[:-1]) * numpy.abs(dt) / 2 return arc_lengths, t if num_vertices is not None: - n_pts = max(self.radii) / min(self.radii) * num_vertices * 100 + n_pts = numpy.ceil(max(self.radii) / min(self.radii) * num_vertices * 100).astype(int) perimeter_inner = get_arclens(n_pts, *a_ranges[0])[0].sum() perimeter_outer = get_arclens(n_pts, *a_ranges[1])[0].sum() implied_arclen = (perimeter_outer + perimeter_inner + self.width * 2) / num_vertices @@ -233,7 +233,7 @@ class Arc(Shape): """ Figure out the parameter values at which we should place vertices to meet the arclength constraint""" dr = -self.width / 2.0 * (-1 if inner else 1) - n_pts = 2 * pi * max(self.radii) / max_arclen + n_pts = numpy.ceil(2 * pi * max(self.radii) / max_arclen).astype(int) arc_lengths, thetas = get_arclens(n_pts, *a_ranges[0 if inner else 1]) keep = []