Pomax / bezierjs

A nodejs and client-side library for (cubic) Bezier curve work
MIT License
1.7k stars 230 forks source link

Rational Bezier Curve Support #197

Open pkuimyy opened 1 year ago

pkuimyy commented 1 year ago

I want to calculate the derivative function of a rational bezier function. Have you considered to support rational bezier curve in this library? Thank you for the document "A Primer on Bézier Curves" which helps me a lot.

Pomax commented 1 year ago

Hm, that's a good point. Adding a section for the derivative of the rational Bezier to the primer would be a good idea.

As for this library, it's kind of in need of a rewrite to make adding new code easier (or, "doable", really), and unless someone wants to fund that effort I have an embarrassingly high amount of other projects that all compete for my time and energy, with this one being pretty low on the list.

In the mean time, https://www.mn.uio.no/math/english/people/aca/michaelf/papers/bez.pdf should help, function (11) should let you compute the derivative fairly quickly (but pay attention to the notation, where P₀,₀ is the first point, P₀,₁ the second point, etc. and P₁,₀ the first point in the first de Casteljau iteration, P₁,₁ the second, P₂,₀ the first point on the second de Casteljau iteration, and so on and so on)