Tangents or normals to a path - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +--- Thread: Tangents or normals to a path (/Thread-Tangents-or-normals-to-a-path) |
Tangents or normals to a path - Ottia Tuota - 12-19-2020 A couple of new tools to manipulate paths. Inkscape can do snapping to paths both tangentially and perpendically. (In Inkscape, see Document Properties > Snap, and tick the two points at the bottom.) Nothing similar exists in Gimp(?). I made a sort of "poor man's snap" to imitate that feature. It is no real snapping as in Inkscape. The package consists so far of four plugins:
http://kmarkku.arkku.net/Path_tangents_files/Gimp_master.html and click the Download button at the bottom. That gives you a ZIP file. Unzip it and place the one file it contains (path_tangents.py) in your user's plugins folder. Start Gimp. In the Paths tab, right click some path and follow the link Tools > Tangents and normals > ... Bounding box does what its name says. Actually the code has been finished for a long time but it was buried in another plugin, and I felt that it deserves to be a plugin on its own right. I placed it in this package since it is, loosely speaking, about tangents. Of the other plugins I explain here number 3: "Tangents or normals from a point". The rest will follow in another post. Tangents or normals from a point: Suppose you have a path and you need to draw a tangent to it from some point. In the picture below the Path is in blue. I marked the point with a black dot but that is only for this explanation. It is just some point in the plane. The red line is the tangent you want to draw. [attachment=5371] You use the plugin as follows. Make a tentative tangent: a line segment (a path with 2 anchors), one end precisely at the point you want, and the other end somewhere close to where the tangential point should be: [attachment=5372] Then call the plugin by right-clicking at Path (in the Paths tab), follow the link Tools > Tangents and normals > Tangents or normals from a point click it, and choose your tentative tangent in the GUI. Otherwise keep the default values. The plugin creates the tangent as a new path: [attachment=5373] You can think that your tentative tangent is "snapped" to the tangential point. The plugin offers three other inputs:
I explain now the Action: There are three options:
[attachment=5374] The first option (default) draws one tangent, closest to the tentative tangent. The second draws all possible tangents for one stroke, the closest one (here it is the largest circle). And if you choose "Draw all" you get all possible tangents for the whole path. See the picture: [attachment=5375] If you find any strange behaviours, please report. Or if you have any suggestions, please tell me. Sorry for the long posting. To be continued... RE: Tangents or normals to a path - Ottia Tuota - 12-19-2020 I continue with the package of four plugins (see post #1):
Parallel tangents or normals: Just as in number 3, you input a path and a tentative tangent (a line segment, a path with two anchors). [attachment=5381] The plugin draws tangents which are parallel to the tentative tangent. (Number 3 made tangents drawn from one point.) With Actions="Draw only the closest" (default) and "Draw all" you get: [attachment=5382] Note that the tangents are copies of the inputted tentative tangent (with the middle anchor added). If you need longer tangents, use a longer tentative tangent. There is no "Extend" option here. Tangents or normals from a stroke end of another path: The idea here is that you have a path and you need to draw to it a tangent which should extend some stroke of another path. (Plugin number 3 drew tangents from one point but here you can make them extend some stroke). You input three paths:
You make the tentative tangent close to where you would like the tangent to be: [attachment=5384] Then you call the plugin and get: [attachment=5385] Both ends of the tentative tangent are "snapped" to the proper places. Note that this is no real snapping: the plugin makes a new copy of the whole path with the one stroke extended. (It would be nice to achieve this without having to build a new copy of the path. But I don't know how that could be accomplished in a plugin, since for example we don't know if the extension should be made to the head or to the tail end of the stroke. And the pdb does not contain all functions one would wish.) As in number 3, this plugin offers three other inputs: "Tangents or normals?", "Action", and "Extend". They work as before. Please try these yourself. I hope that somebody will find these plugins useful. If there are any problems, please tell me. Any suggestions are welcome. RE: Tangents or normals to a path - Ofnuts - 12-19-2020 (12-19-2020, 07:18 PM)Ottia Tuota Wrote: I continue with the package of four plugins (see post #1): Cool stuff. RE: Tangents or normals to a path - Ottia Tuota - 12-19-2020 I appreciate your words. The equations to be solved are up to degree 5. RE: Tangents or normals to a path - denzjos - 12-26-2020 Nice, easy to use. RE: Tangents or normals to a path - Ottia Tuota - 12-29-2020 (12-26-2020, 07:59 AM)denzjos Wrote: Nice, easy to use. Thanks, denzjos, nice to hear. By the way, there will still be one more plugin in this package. But not now. Some time next year... RE: Tangents or normals to a path - Ottia Tuota - 01-10-2021 The package got a new addition: a plugin called "Common tangent or normal between two paths". You get it from http://kmarkku.arkku.net/Path_tangents_files/Gimp_master.html as before. The new plugin tries to draw a common tangent of two paths. Or a common normal. Or a line segment which is a tangent to one of the paths and a normal to the other path. A picture: [attachment=5455] The path is the right-clicked path, and the other path is inputted in the GUI of the plugin. You give a tentative tangent (a line segment) where you think the tangent should be, and the plugin tries to snap it to be a real tangent. In the next picture on the left, the plugin has drawn a common normal between the two paths. You make first a tentative common normal and so on. On the right you see a line segment that is a tangent of the path and a normal of the other path. [attachment=5456] I don't guarantee that the plugin works well in all cases. It differs from the others in the package. Instead of solving an equation, the plugin does an iterative search. It is crucial that the tentative tangent is rather accurate (it gives the starting point for the iteration). If you find some difficult cases, please tell. In case you are interested: The idea in the implementation is to iterate, and at each iteration step to try to solve the (hard) pair of equations involved. But that pair of equations cannot be solved exactly, so what is solved is its linear approximation. Then the solution is far from exact, hence the iteration, hoping it to converge towards the exact solution. In the few cases I have tried the plugin has worked well. But as I said, I don't guarantee anything. And there is one fact that is not really worth mentioning but here goes. The problem is: what to do when the tangent or normal to be drawn is of zero length? Normally the plugin draws the tangents or normals between two points that are well separated. But it may happen that the two paths have a common tangent (or normal) at a point where they meet; in other words, they meet tangentially (or perpendically). Then the plugin should draw a line segment of zero length. I don't really know what would be a good way to handle such cases. But currently the plugin treats such cases in an exceptional way: instead of a zero length line segment it draws it to have the same length as the tentative tangent (normal). I am not happy with this, to make the plugin to switch to exceptional behaviour in such special cases that are very rare in practice. And I believe that if the user knows how to create two paths meeting precisely tangentially (or perpendically), (s)he probably also knows how to draw the common tangent (normal) without any plugins. But here is an example: [attachment=5457] On the left the paths (two parabolas) meet tangentially and the plugin has found and drawn the common tangent. On the right two parabolas meet perpendically, and the plugin has drawn a common tangent-normal. RE: Tangents or normals to a path - denzjos - 01-10-2021 (01-10-2021, 03:04 PM)Ottia Tuota Wrote: The package got a new addition: a plugin called "Common tangent or normal between two paths". You get it fromThe last 'l' is missing in the link, the correct link is : http://kmarkku.arkku.net/Path_tangents_files/Gimp_master.html RE: Tangents or normals to a path - Ottia Tuota - 01-10-2021 (01-10-2021, 04:24 PM)denzjos Wrote: The last 'l' is missing in the link, the correct link is : http://kmarkku.arkku.net/Path_tangents_files/Gimp_master.html Thanks, you are right. I don't find any way to edit my post, so the right link is now in your post. |