Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inaccuracy reproducing a bezier #5

Open
LeanderSilur opened this issue Sep 1, 2020 · 0 comments
Open

Inaccuracy reproducing a bezier #5

LeanderSilur opened this issue Sep 1, 2020 · 0 comments

Comments

@LeanderSilur
Copy link

When you get samples points from an existing bezier, and fit a curve to those points, the original bezier is inaccurately reconstructed.

>>> import bezier
>>> from fitCurves import fitCurve
>>> import numpy as np
>>> import sys
>>>
>>> points = np.array([[0, 0], [5,50], [50,40], [75,50]], dtype=np.float32)
>>> samples_t = np.linspace(0, 1, 100, dtype=np.float32)
>>> samples_pt = [bezier.q(points, t) for t in samples_t]
>>> calculated_bezier = fitCurve(samples_pt, sys.float_info.max)
>>>
>>> print(calculated_bezier)
[[array([0., 0.], dtype=float32), array([ 4.945499, 45.22236 ], dtype=float32),
array([42.795097, 37.474834], dtype=float32), array([75., 50.], dtype=float32)]]

>>> print(np.array(calculated_bezier) - points)
[[[ 0.          0.        ]
  [-0.05450106 -4.7776413 ]
  [-7.2049026  -2.5251656 ]
  [ 0.          0.        ]]]

(I am very grateful for your port of this function to python!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant