I'm thinking of implementing an add-on (using Python) for Lagrange curves. In short (after an instance has been added), in Object Mode
there should just be a curve (i.e. the parametric curve evaluated at a couple of parameter values subsequently connected by line segments) like a Bézier curve, whereas in Edit Mode
there should be a control net as well (similar to the control net of a NURBS curve) that allows the user to change/modify the curve. In addition, it should be possible to assign a numerical value to each point/vertex and edge of the control net.
My approach would be to draw the curve using bgl
(given a polynomial degree, the values assigned to the edges could act as parameter spans, thereby defining Lagrange basis functions — any position on the curve can then be computed as the sum of the control points multiplied by their associated basis functions). However, I'm not sure how to make the curve into an actual object (such that it can be selected, saved, ...). In addition, it should still be possible to change the resolution of the curve at a later time.
Next, how/where to store the control net and additional information? My approach would be to create a mesh for this purpose and store values in a bmesh
layer. In Object Mode
this mesh should be hidden. But how to link it to the curve (changing values re-defines the basis functions which should result in a different curve, likewise moving control points should change the curve)?
I realize this is a rather comprehensive question -- I'm fairly familiar with bmesh
but apart from simple scripts I don't have much experience coding things in Blender. Any thoughts on a general workflow (see steps/outline above) or references to similar add-ons would be much appreciated!