accurate bezier curve fitting

42 views
Skip to first unread message

vince touache

unread,
Jun 1, 2021, 8:50:34 AM6/1/21
to Python Programming for Autodesk Maya
hello,

I was looking for an algorithm to predict the best Bezier curve, given a vector of points. I ended up implementing  "An Algorithm for Automatically Fitting Digitized Curves" from Graphics Gems vol.1, but I'm not 100% happy with the result.
Out of curiosity, I compared it against the fitBspline node in Maya, which seems to give a better result.

Does anyone know what algorithm the fitBspline node is using internally? And/or does anyone know other bezier curve fitting algorithms?

TLDR:
what I don't like with the Graphics Gems approach is that it assumes the tangent is the unit vector P1-P0 / ||P1-P0||, which is always wrong. Close to be right, but not right. So I'd like something that can retrieve the tangents more accurately

Thank you

Alok Gandhi

unread,
Jun 1, 2021, 9:24:28 AM6/1/21
to python_in...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/7062536a-121b-4112-85da-24ebc99f8d3an%40googlegroups.com.

Marcus Ottosson

unread,
Jun 1, 2021, 1:43:29 PM6/1/21
to python_in...@googlegroups.com
Would it be possible to post the results you weren't happy with, along with the results in Maya you thought gave better results?

vince touache

unread,
Jun 1, 2021, 2:25:19 PM6/1/21
to Python Programming for Autodesk Maya
@Marcus: as you can see, fitBspline (green) produces a better result than my version (red). Moreover, it requires way too many controls. My original curve is 4 CVs, so I would expect a solution close to 4 CVs as well. You can see the difference b/w mine and the maya one on fitting_curve1.jpg and fitting_curve2.jpg (closeup)
@Alok: the problem with what's exposed here is the same (I believe) as the one coming with the Graphics Gems solution. I didn't find an implementation, so I may be wrong, but seems that at no point the partial derivative is actually discussed. Instead, they just take P1-P0 (in yellow on fitting_curve3.jpg) to be the tangent (from P0->Pn, with n input points), but the "true" tangent is different (in red on fitting_curve3.jpg). Of course, the algorithm has no idea of this true tangent, since all it gets is a vector of input points.

Hope it makes sense

Thank you

fitting_curve2.JPG
fitting_curve1.JPG
fitting_curve3.JPG
Reply all
Reply to author
Forward
0 new messages