Diederik en Rezi wrote:
Aaron Spike wrote:
Diederik van Lierop wrote:
Snapping any Beziér path tangentially to any another object however requires quite some sophisticated programming unfortunately. So although it's very useful, don't expect such a feature any time soon :-(.
What sort of sophisticated programming is needed? Could we discuss what would be necessary for tangential bezier snapping?
I think that the 2geom library should provide a function to find all parallel segments and subsequently return the shortest distance (vector) in any set of parallel segments, where the segments are a part of Bezier curves in different objects. I'm not familiar with these libraries (are we sure such a function isn't implemented yet) and I don't have a clue how to code such a function. So maybe sophisticated is only relative?
Diederik
The mathematics of a tangent snap will depend on the type of objects that are being snapped together. The simplest case would be snapping a straight line to a Bezier curve. The mathematics should not be too terribly complex; You would need to compute the location of the intersection of a line with the curve, which in general will a number of solutions ranging from none up to an upper limit determined by the degree of the curve. A tangent solution is found by imposing an additional requirement that the derivative of the Bezier curve at a point of intersection must be the same as the slope of the intersecting line. Again, there are multiple solutions possible, depending on the degree of the curve, some of which can be rejected because they might not be between the endpoints of the curve. A unique solution can be obtained by picking the tangent line that is closest to the line defined by the startpoint of the intended tangent line and the current position of the cursor. There is nothing hugely difficult about this. You can be quite certain that it has already been worked out somewhere in the published mathematical literature of Bezier curves.