[solved] Find intersection point between line and rectangle

Post questions on how to use or achieve an effect in Inkscape.
srynoname
Posts: 22
Joined: Mon Jan 16, 2017 12:52 am

[solved] Find intersection point between line and rectangle

Postby srynoname » Wed Aug 23, 2017 5:31 am

Hi all,

I need to find the intersection point between a rectangle and a line as shown in the following sketch.
inkscape.jpg
inkscape.jpg (104.04 KiB) Viewed 2801 times

How can this be done? I don't need to create a node on this point or something else, I just need the coordinates where the line and the rectangle intersect for processing outside of Inkscape.

Thanks for any hints on this :-)

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Find intersection point between line and rectangle

Postby ragstian » Wed Aug 23, 2017 6:09 am

Hi

Turn on all snapping options.
( or at least: Snap guides, Snap to intersections )

Pull in a guide from ruler on side, (by click and hold left mouse button on the ruler) drag line (mouse pointer) to
intersection point, release mouse button when it snaps to the intersection.

Double click on the created guide line to get the guide line properties window to open,
pop up window will state the coordinates of the "origin" of the guide line,
the coordinates will be the intersection point.

If you need an explanation with figures please chime back.

The "pathmonkey_mutual_cut_line.py" ( found here ) extension could easily be modified to list the coordinates as well.
The extension was created by Gary Kacmarcik. Link to pathmonkey.
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

srynoname
Posts: 22
Joined: Mon Jan 16, 2017 12:52 am

Re: Find intersection point between line and rectangle

Postby srynoname » Thu Aug 24, 2017 5:11 am

ragstian, that worked great! thank you!

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

Re: [solved] Find intersection point between line and rectangle

Postby theozh » Thu Aug 24, 2017 3:39 pm

Certainly, @ragstian's solution is the preferred solution.
If @srynoname doesn't mind creating a node at this location there should be another way even without guide.

1. set snap intersections
2. select line
3. use node tool (F2)
4. double click to create a new node when "Handle to path intersection" appears
5. select the newly created node and read the coordinates from the Tools control bar.

BUT: Inkscape doesn't behave as expected.
The node is NOT necessarily created precisely at the intersection as you might expect, but somewhere nearby. Why?

Bug or feature? Or wrong expectations?

IntersectionHandle.png
IntersectionHandle.png (5.71 KiB) Viewed 2729 times
Win7/64, Inkscape 0.92.2

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

Re: [solved] Find intersection point between line and rectangle

Postby theozh » Mon Aug 28, 2017 7:31 pm

ok... FWIW...
Creating a node via snapping to intersection apparently behaves a bit special.

It seems that the relative position of the node tool/handle to the intersection determines where the new node will be created.
Assume you have one path selected and the other one unselected. If "Handle to path intersection" is displayed there are two cases:
a) If the position of the handle is closer to the selected path the new node will be created somewhere on the selected path but not necessarily at the intersection
b) If the position of the handle is closer to the unselected path the new node will be created at the intersection on both paths.
However, no nodes are created on objects like rectangles or circles. OK, fine.
However, at an intersection of a line/path with a circle there will be even no node created on the intersecting line. Strange?!

Phew! Pretty confusing and a bit inconsistent.
In any case I would expect a node being created at the intersection as soon as it says "Handle to path intersection".
Win7/64, Inkscape 0.92.2

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

Re: [solved] Find intersection point between line and rectangle

Postby tylerdurden » Mon Aug 28, 2017 9:40 pm

Seems to be some tolerance in the location-tooltip, so I'd avoid using the status display as an accurate indicator of location.

Snapping a guide to path intersection works pretty well, even with arcs & beziers.
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: [solved] Find intersection point between line and rectangle

Postby theozh » Mon Aug 28, 2017 9:48 pm

@tylerdurden, yes, snapping guides to intersections works, no doubt. That's why @ragstian's solution with guides is the "secure" solution.
However, my point is that creating a node with the node tool together with snapping shows some inconsistency.
Win7/64, Inkscape 0.92.2

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: [solved] Find intersection point between line and rectangle

Postby Moini » Mon Aug 28, 2017 11:44 pm

@theozh : can you check if that bug is already reported? Especially a) is a bit of a nuisance... (I didn't know it could create two nodes, one on each path!)
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

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

Re: [solved] Find intersection point between line and rectangle

Postby theozh » Tue Aug 29, 2017 12:24 am

@Moini, yes, a) is definitely not straightforward, especially when it doesn't snap to the intersection although it says so.
Although, I guess this behaviour with the proximity of the handle might be intentional (or still by accident?).

sorry, haven't mentioned it... already done...
https://bugs.launchpad.net/inkscape/+bug/1713439
Win7/64, Inkscape 0.92.2


Return to “Help with using Inkscape”