From 03d85feabed05727660aa3ecd151d583646869d0 Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Sat, 13 Jan 2018 21:34:43 -0700 Subject: [PATCH] replace Line.point_to_t() implementation with radialrange() Instead of computing Line.point_to_t() "by hand" using the parametric equation of the Line, call the already existing radialrange() function. --- svgpathtools/path.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/svgpathtools/path.py b/svgpathtools/path.py index 3a13504..6a8824b 100644 --- a/svgpathtools/path.py +++ b/svgpathtools/path.py @@ -617,12 +617,10 @@ class Line(object): elif np.isclose(point, self.end, rtol=0, atol=1e-6): return 1.0 - p = self.poly() - # p(t) = (p_1 * t) + p_0 = point - # t = (point - p_0) / p_1 - t = (point - p[0]) / p[1] - if np.isclose(t.imag, 0) and (t.real >= 0.0) and (t.real <= 1.0): - return t.real + (near_d, near_t), (far_d, far_t) = self.radialrange(point) + if np.isclose(near_d, 0, rtol=0, atol=1e-6): + return near_t + return None def cropped(self, t0, t1):