mathandy / svgpathtools

A collection of tools for manipulating and analyzing SVG Path objects and Bezier curves.
MIT License
557 stars 142 forks source link

QuadraticBezier segment length() function gives 'inf' as result #186

Open xmarduel opened 2 years ago

xmarduel commented 2 years ago

for the points: st = (335.43211 + 69.71516199999999j) end = (335.27971 + 69.86756199999999j) ctrl = (335.33051+ 69.816762j) segment= svgpathtools.QuadraticBezier(st, ctrl, end) len = segment.length() # len is 'inf' !!!

Note that for the points: st = (335.43211 + 69.715162j) end = (335.27971 + 69.867562j) ctrl = (335.33051 + 69.816762j) the length of the segment is ok : 0.21552614690565985

[python-3.10]

Sincerely, XM

MaybeJustJames commented 1 year ago

I have another test case:

import svgpathtools

from svg.path import path as svgpath

def bad():
    path = svgpathtools.QuadraticBezier(
        start=(46 + 125j), control=(45.8 + 124.6j), end=(45.7 + 124.4j)
    )
    return path.length()

def good():
    path = svgpath.QuadraticBezier(
        start=(46 + 125j), control=(45.8 + 124.6j), end=(45.7 + 124.4j)
    )
    return path.length()

assert bad() == good()

This is parsed from the path "M 46.0 125.0 Q 45.8 124.6, 45.7 124.4"