fix Arc.center being nan cause of switch to np.sqrt raising different error than math.sqrt

vectorize-path-point
Andrew Port 2020-12-08 18:21:24 -08:00
parent 44e88d54e5
commit 30f517e735
3 changed files with 534 additions and 27 deletions

View File

@ -1462,10 +1462,8 @@ class Arc(object):
# plugging our transformed endpoints (x_1', y_1') and (x_2', y_2')
tmp = rx_sqd*y1p_sqd + ry_sqd*x1p_sqd
radicand = (rx_sqd*ry_sqd - tmp) / tmp
try:
radical = sqrt(radicand)
except ValueError:
radical = 0
radical = 0 if np.isclose(radicand, 0) else sqrt(radicand)
if self.large_arc == self.sweep:
cp = -radical*(rx*y1p/ry - 1j*ry*x1p/rx)
else:

551
tags

File diff suppressed because it is too large Load Diff

View File

@ -656,7 +656,9 @@ class ArcTest(unittest.TestCase):
orig_t = random.random()
p = a.point(orig_t)
computed_t = a.point_to_t(p)
self.assertAlmostEqual(orig_t, computed_t, msg="arc %s at t=%f is point %s, but got %f back" % (a, orig_t, p, computed_t))
self.assertAlmostEqual(orig_t, computed_t,
msg="arc %s at t=%f is point %s, but got %f back"
"" % (a, orig_t, p, computed_t))
def test_approx_quad(self):
n = 100