2 ms·
So I looked into this a bit more. I think the optimisations in the calculations threw me off a bit, but I understand now: - to draw a curve, it has some start
by dan-robertson 6y ago
So I looked into this a bit more.
I think the optimisations in the calculations threw me off a bit, but I understand now:
- to draw a curve, it has some starting angle and you move a small amount in that direction and then adjust the angle. The rate the angle changes is the signed curvature.
- therefore the angle change over the whole curve is the integral of the curvature between 0 and 1. (This simplifies the differential equations into dX/ds = (cos theta, sin theta), dtheta/ds = k.)
- because we don’t care about the initial angle, there’s a trick in the way an integral is computed to simplify the code (\int_{1-s}^1 f(s) ds = \int_0^1 f(s) ds - \int_0^{1-s} f(s) ds, but the first term is a constant so can be folded into the starting angle).
- the k0,k1,bias0,bias1 parameters give curves but they don’t much correspond to the things you care about (initial and final angle relative to the chord and chord length relative to arc length), so to go from the parameters you want to the curve, you do an optimisation step to find a curve for your desired parameters. This feels a bit expensive (you need to effectively solve the differential equation above to find the chord length. Maybe there’s an analytic solution (surely there is when f is polynomial) but there’s 8-18 cases and the integrals look gnarly)
- there’s an error in the definition of the basis function in the bias<1 case, it should be doubled.
I guess a thing I still don’t understand is what motivates the particular choice of the basis function. There doesn’t seem to be anything very natural about either of the cases. I was also thrown off by the definition of k because I expected it to be roughly like interpolation (I.e. f(b,-) would always be strictly increasing with f(b,0)=0,f(b,1)=1), but f(b,1) can range over a pretty wild set of values.)