[solved] How to get two paths in touch?

Post questions on how to use or achieve an effect in Inkscape.
theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

[solved] How to get two paths in touch?

Postby theozh » Mon Mar 27, 2017 10:34 pm

How can you get two paths in touch (in a mathematical sense), so that they do not intersect but just touch in exactly one point?

Let's assume that one path (blue) is fixed and the touching point on it is defined whereas the other path (black) can be shifted in x- and y-direction (no rotation).

I know how to draw tangents (red) to a curve at certain nodes:
Extensions | Vizualize Path | Draw Handles

I also know that you can snap a straight line perpendicularly or tangentially to a path (but not from a path)
File | Document Properties | Snap | Miscellaneous | ...

But then...? How to proceed?
Basically, I need to create a node at the point on the black path which has the same rise as the red tangent of the blue path. But how?

PathsInTouch.png
PathsInTouch.png (2.55 KiB) Viewed 1811 times
Last edited by theozh on Tue Mar 28, 2017 9:10 pm, edited 1 time in total.
Win7/64, Inkscape 0.92.2

tylerdurden
Posts: 2344
Joined: Sun Apr 14, 2013 12:04 pm
Location: Michigan, USA

Re: How to get two paths in touch?

Postby tylerdurden » Mon Mar 27, 2017 11:38 pm

Just thinkin out loud....

If the second path mustn't rotate, there is only one point that can touch (I think).

So a line parallel to the first path's handles, that just touches the second path should identify the point.

Image
Last edited by tylerdurden on Tue Mar 28, 2017 9:13 am, edited 2 times in total.
Have a nice day.

I'm using Inkscape 0.92.2 (5c3e80d, 2017-08-06), 64 bit win8.1

The Inkscape manual has lots of helpful info! http://tavmjong.free.fr/INKSCAPE/MANUAL/html/

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: How to get two paths in touch?

Postby theozh » Tue Mar 28, 2017 6:38 am

Thanks, @tylerdurden,
As I understand from your GIF-tutorial, the center node of the duplicated tangent snaps to the second path. You also show by zooming in that the contact seems to be only in one point. How can you be sure that this is not just a lucky strike?

If I move the duplicated tangent it can snap to several positions on the path depending on how I approach the path. Do you use further options? Maybe I missed an important detail?

SnapToPath.png
SnapToPath.png (9.66 KiB) Viewed 1765 times
Win7/64, Inkscape 0.92.2

tylerdurden
Posts: 2344
Joined: Sun Apr 14, 2013 12:04 pm
Location: Michigan, USA

Re: How to get two paths in touch?

Postby tylerdurden » Tue Mar 28, 2017 8:56 am

You are correct, the alignment is rather arbitrary, so I zoomed-in very close to demonstrate casual accuracy.

I'm not sure Inkscape can identify the actual closest point, but maybe someone can develop a reliable method.

And, while theoretically only one point is actually the closest, depending on your needs, there might be be a small range of points that will be "close enough".
Have a nice day.

I'm using Inkscape 0.92.2 (5c3e80d, 2017-08-06), 64 bit win8.1

The Inkscape manual has lots of helpful info! http://tavmjong.free.fr/INKSCAPE/MANUAL/html/

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: How to get two paths in touch?

Postby Lazur » Tue Mar 28, 2017 9:40 am

Not sure about tangential snapping, I couldn't really use it yet.
So as usual, here is a rather theoretic-brute-forcing method.

Once you know the angle of the desired tangent point, rotate the other path with that value in the opposite direction, so that it will be a vertical extreme point at the top;
press Ctrl++ and the "bug becomes a feature": a new node is added at the top of the bounding box. Time to rotate back to the original direction.

Doesn't really work if the path is concave. Or at all...

Had a very similar problem of adding nodes at given angles to a path here.
However I couldn't solve it, my conclusion is that as the Bézier is not an "accurate curve", better construct the nodes before and then you cannot go wrong.

Like, in this case, add a new node on the second curve by eye, snap the two nodes together, and snap the new smooth nodes handle to the other handle's direction...

Guess a dropper tool you could use for copy/pasting node handle directions could speed up the -still rather overcomplicated- construction.


(On the linked problem the proper solution would be plotting the curve with parametric functions, with the option to have samples instead for t, for the resulting curve's given angles. Basically that would mean derivative function equations for each node plotted...)

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: How to get two paths in touch?

Postby brynn » Tue Mar 28, 2017 9:52 am

Building on td's idea, and without a cool animation.

Join the endnodes of the 2 tangent handles (in the middle of the blue curve) to create a single path. Don't delete the middle node.
Duplicate the tangent line.
Object menu > Object to Guide
Drag the guide slowly around the area of the black curve, where it looks like it's going to be tangent. I don't know any way around this bit of guessing.
You have to have the snap indicator turned on (Inkscape Preferences), to see when you've snapped tangentially, and not just snapped to the path.

For snapping options, the next part might be easier if you have the option in Inkscape Preferences to snap the node closest to the pointer.

Grab the original tangent line near the middle node, and drag it over to the black curve. (You only need to grab at a point closer to the middle node, than to the other nodes - not exactly on the middle node.)
Snap it to the guide origin, which will also be the tangent point for the black curve.
Group the original tangent line with the black curve.
Drag the group back over to the blue curve (grab it near the middle node of the tangent line).
Snap to the node on the blue curve.

I might have some other options enabled (or disabled) which allows this to work. Especially certain snap options might need to be tweaked as you go. But I think I remembered them all. I wouldn't have figured it out except for learning about making the tangent line using Show Handles extension from theozh; and td's idea about using the original tangent line to get a parallel line for the tangent for the black curve. Everyone learns!

(Lazur posted while I was typing, haven't read it yet.)

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: How to get two paths in touch?

Postby brynn » Tue Mar 28, 2017 9:58 am

I don't know why you can't snap the middle node of a path tangentially to another path. That was my first try. But when I tried a guide, that worked. It seems like if the origin of a guide will snap tangentially to a curve, then a node on a straight path ought to. But it wasn't working for me. Maybe didn't have snap options right?

Edit
Well, I understand more now, than I did when Lazur first was working on that other project. But some if it still is over my head :roll:

tylerdurden
Posts: 2344
Joined: Sun Apr 14, 2013 12:04 pm
Location: Michigan, USA

Re: How to get two paths in touch?

Postby tylerdurden » Tue Mar 28, 2017 12:39 pm

Lazur wrote:Once you know the angle of the desired tangent point, rotate the other path with that value in the opposite direction, so that it will be a vertical extreme point at the top; press Ctrl++ and the "bug becomes a feature": a new node is added at the top of the bounding box. Time to rotate back to the original direction.

That works well.
Have a nice day.

I'm using Inkscape 0.92.2 (5c3e80d, 2017-08-06), 64 bit win8.1

The Inkscape manual has lots of helpful info! http://tavmjong.free.fr/INKSCAPE/MANUAL/html/

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: How to get two paths in touch?

Postby theozh » Tue Mar 28, 2017 4:51 pm

Thanks, @Lazur, well that's a somehow possible method.
I didn't know about the "Self-Union-Top-Point-Creation-Bug/Feature" ;)
However, if you have an open path it will be closed by Ctrl++ and you have to re-open it again. Well, as you said: "brute force".

@brynn, guides might be also an idea. However, I haven't understood why and how they are snapping to a path. Sometimes perpendicular, rarely tangentially, sometimes they do adapt to the path with a precision of maybe 1°, sometimes they do not adapt...
maybe I should check the manual to get a better understanding how they really work.
Win7/64, Inkscape 0.92.2

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: How to get two paths in touch?

Postby brynn » Tue Mar 28, 2017 7:58 pm

I think there's an option somewhere to snap guides while dragging the guide.....at least there used to be. Maybe it's just default behavior now, because I can't find that option now. Or maybe it was moved, or given a different name or description?

In this case, it's important to use object to guide, so the guide is precisely parallel to the tangent line (as per td's theory).

One of my favorite tips for snapping, is to only have the snap options enabled that you need for each particular move. That way, it's not even trying to snap things that you don't want to snap. In this case, I had only snap to path, and snap guides enabled (also tangential, in Doc Prop, of course). Everything else disabled. (Also, snap node closest to pointer in Inks Props, as I mentioned. Although I'm not sure if that came into play for the tang snap.)

When I was trying, I would slowly drag the guide along the curve, in the area where I was expecting. It snapped "guide origin to path" maybe 6 or 8 times before I finally saw the "guide origin to path (tangential)" notification. Then I released the mouse. Oh and also, sometimes I find that zooming in allows me to make a snap that was absolutely impossible when zoomed out. I was zoomed in, on purpose, to make the tang. snap. I had zoomed the original tangent line to fit the window, for an example of how close I was zoomed (but scrolled down slightly to the black curve). And my curves were roughly the same size/shape as yours (by visual estimate).

I'm not sure what you mean about the guide adapting to the path. Do you mean that it's rotating somehow?

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: How to get two paths in touch?

Postby theozh » Tue Mar 28, 2017 9:10 pm

Yes, @brynn, obviously a guide can snap perpendicularly and tangentially to a path.
Apparently, when creating a new guide it will snap perpendicular to the curve, if you have snapping perpendicular & tangentially enabled. Moreover, if this guide is once placed and you'll move it again it will keep its angle.

With this, I think I found an almost practical way:
1) enable snapping perpendicular, tangentially (File | Document Properties | Snap | ...)
2) enable snap to path, enable snap to guides, disable snapping to all other nodes, intersections,...
3) create a guide (cyan) to snap (perpendicular) to the desired contact point on the first path (blue)
4) draw a straight line (black) with first node snapping to the (cyan) guide in some distance to the first curve and the second node snapping (perpendicular) to the first path (blue), i.e. touching point
5) create a second guide (red) which is snapping perpendicular to this (black) line.
6) Obviously if you now shift this (red) guide it will not change its rise (or angle). Drag this guide to the second path (black) until it snaps tangentially.
6) enable snap to Cusp-node
7) Duplicate the (black) straight line, move it and let it snap to the origin of the (red) guide on the second path (black)
8) group this line and the second path
9) move this group and let it snap (Cusp-node to Cusp-node) to the first black line, i.e. touching point (here shown as a green duplicate)
10 ungroup and delete unwanted helpers

Maybe there are still simplifications possible.
At least, with this method the second path will not be altered/modified as in @Lazur's rotation approach.

TouchPaths2.png
TouchPaths2.png (6.11 KiB) Viewed 1671 times
Win7/64, Inkscape 0.92.2

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: [solved] How to get two paths in touch?

Postby theozh » Tue Mar 28, 2017 11:57 pm

A simplification: see GIF-Demo:

By double clicking on a guide you get a dialog where you can rotate a guide relative by 90°, i.e. making it from perpendicular to tangent.

The following might additionally help to let only the intended node snap:
Menubar | Edit | Preferences | Behaviour | Snapping | Only snap the node closest to the pointer

Image
Win7/64, Inkscape 0.92.2

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: [solved] How to get two paths in touch?

Postby brynn » Thu Mar 30, 2017 7:03 pm

Object menu > Object to Guide is the key to the steps I made.

No need to create new guide and manipulate it to fit what you need. Just duplicate the tangent path, and Object to Guide.

As we often find in Inkscape, there are more than 1 way to reach a particular goal.

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: [solved] How to get two paths in touch?

Postby theozh » Thu Mar 30, 2017 8:54 pm

Yes, "object to guide" is a possibility to get a tangent guide if you have used the extension "draw handles" beforehand.

I prefer to use the basic drawing tools and use extensions only if absolutely necessary (or if there is a clear advantage).
Actually, if you disable "snap perpendicular" and only allow "snap tangentially" you will directly get your tangential guide. No need for extra rotation as shown in the GIF-Demo.
Other advantages over the "draw handles"-approach:
- you will not get hundreds of handles (and consequently guides) if you have a more complex first path
- you still can freely choose your touching point and you are not limited to an existing (or to be created) node on the first path

Agree... or as Perl-people would say: TIMTOWTDI
or Python-people:
"There should be one — and preferably only one — obvious way to do it."
https://www.python.org/dev/peps/pep-0020/
Win7/64, Inkscape 0.92.2


Return to “Help with using Inkscape”