Merge remote-tracking branch 'origin/master' into vectorize-path-point

vectorize-path-point
Andrew Port 2020-12-08 19:56:46 -08:00
commit 2824a26a6c
3 changed files with 538 additions and 34 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:

549
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
@ -1379,9 +1381,7 @@ class Test_intersect(unittest.TestCase):
self.assertAlmostEqual(xy[0], yx[1])
self.assertAlmostEqual(xy[1], yx[0])
self.assertAlmostEqual(x.point(xy[0]), y.point(yx[0]))
self.assertTrue(len(xiy), len(yix))
self.assertTrue(len(xiy), 2)
self.assertTrue(len(yix), 2)
self.assertTrue(len(xiy) == len(yix))
# test each segment against another segment of same type
for x in segdict:
@ -1398,9 +1398,9 @@ class Test_intersect(unittest.TestCase):
self.assertAlmostEqual(xy[0], yx[1])
self.assertAlmostEqual(xy[1], yx[0])
self.assertAlmostEqual(x.point(xy[0]), y.point(yx[0]))
self.assertTrue(len(xiy), len(yix))
self.assertTrue(len(xiy), 1)
self.assertTrue(len(yix), 1)
self.assertTrue(len(xiy) == len(yix))
self.assertTrue(len(xiy) == 1)
self.assertTrue(len(yix) == 1)
###################################################################
def test_line_line_0(self):
@ -1572,7 +1572,6 @@ class Test_intersect(unittest.TestCase):
a0 = Arc(start=(-12.8272110776+72.6464538932j), radius=(44.029+44.029j), rotation=0.0, large_arc=False, sweep=False, end=(-60.6807543328+75.3104334473j))
a1 = Arc(start=(-60.6807101078+75.3104011248j), radius=(44.029+44.029j), rotation=0.0, large_arc=False, sweep=False, end=(-77.7490636234+120.096609353j))
intersections = a0.intersect(a1)
print("intersections: %s" % intersections)
assert_intersections(a0, a1, intersections, 1)
def test_arc_arc_2(self):