Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tangents or normals to a path
#1
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:
  1. Bounding box
  2. Parallel tangents or normals
  3. Tangents or normals from a point
  4. Tangents or normals from a stroke end of another path
To get the plugins, go to

http://kmarkku.arkku.net/Path_tangents_f...aster.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.

   

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:

   

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:

   

You can think that your tentative tangent is "snapped" to the tangential point.

The plugin offers three other inputs:
  • Tangents or normals?
  • Action
  • Extend
The first enables you to draw normals (perpendiculars) instead of tangents, and the third allows you to draw the tangent or normal with an extension. Please try these two yourself.

I explain now the Action: There are three options:
  • Draw only the closest (default)
  • Draw all for the closest stroke
  • Draw all
In the following pictures I show the meanings of the options. The path is the concentric circles. I made there a tentative tangent.

   

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:
 
   

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...
Reply
#2
I continue with the package of four plugins (see post #1):
  1. Bounding box
  2. Parallel tangents or normals
  3. Tangents or normals from a point
  4. Tangents or normals from a stroke end of another path
I explain now numbers 2 and 4. They are rather similar to number 3. I talk only about tangents here. You can try normals yourself.

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).

   

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:

   

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:
  1. The path whose tangent you want to draw (this is the right-clicked path)
  2. Another path whose stroke you would like to extend
  3. Tentative tangent
   

You make the tentative tangent close to where you would like the tangent to be:

   

Then you call the plugin and get:

   

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.
Reply
#3
(12-19-2020, 07:18 PM)Ottia Tuota Wrote: I continue with the package of four plugins (see post #1):
  1. Bounding box
  2. Parallel tangents or normals
  3. Tangents or normals from a point
  4. Tangents or normals from a stroke end of another path
I explain now numbers 2 and 4. They are rather similar to number 3. I talk only about tangents here. You can try normals yourself.

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).



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:



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:
  1. The path whose tangent you want to draw (this is the right-clicked path)
  2. Another path whose stroke you would like to extend
  3. Tentative tangent


You make the tentative tangent close to where you would like the tangent to be:



Then you call the plugin and get:



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.

Cool stuff.
Reply
#4
I appreciate your words. The equations to be solved are up to degree 5.
Reply
#5
Nice, easy to use.
Reply
#6
(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...
Reply
#7
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_f...aster.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:

   

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.

   

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:

   

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.
Reply
#8
(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 from

http://kmarkku.arkku.net/Path_tangents_f...master.htm

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:
.....snip......
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.
The last 'l' is missing in the link, the correct link is : http://kmarkku.arkku.net/Path_tangents_f...aster.html
Reply
#9
(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_f...aster.html

Thanks, you are right. I don't find any way to edit my post, so the right link is now in your post.
Reply


Forum Jump: