Tangent lines?

Post questions on how to use or achieve an effect in Inkscape.
Marscaleb
Posts: 15
Joined: Sat Sep 27, 2014 8:34 am

Tangent lines?

Postby Marscaleb » Tue Dec 02, 2014 12:34 pm

I'm wondering if there is any method to create a curve that automatically has the lines coming off of it to be tangent.

In AutoCAD, I can draw a circle, and then attach two lines to it as tangents. This creates a shape of a straight line going in one direction, curving in a perfect circle, and then proceeding in a straight line toward its next point.
Image

Depending on what various attributes are locked on the object, I could grab the further edge of one of those lines and move it around, and the program automatically will adjust where on the circular curve that line connects to, so that it will always be tangent. For example in the image above, if I grabbed the left point of the upper line and moved it up, the exact spot where it connects to the rounded edge would be brought in a little, making the rounded edge "shorter" so that the line is perfectly tangent to the circle.
Or, I could grab the center point of the circle and move it around, and the size of the circle would change to keep those two lines tangent. For example in the image above, if I moved the center of the circle toward the bottom-left corner, the rounded edge would enlarge, and if I moved it toward the upper right hand corner, the rounded edge would contract until it was just a tiny bevel.

I'm drawing a shape where I want to have such a function. I want to have a perfectly circular rounded edge with smooth nodes. So I have two smooth nodes. But I can't get the bezier curves to be anywhere near a perfect circle without accidentally changing the angle of line into something I don't want. And when I try to fix the other side of the node, I change the angle again, destroying the circle. (Not like I have yet managed to get the bezier curve to look adequately circular, but still...

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

Re: Tangent lines?

Postby Lazur » Tue Dec 02, 2014 12:48 pm

Hi.

In the upcoming 0.91 it is a somewhat adressed feature.

  • Inkscape now also snaps perpendicularly and tangentialy to paths, when creating paths in the pen tool, when dragging nodes, or when manipulating guides. Newly created guides (dragged off the ruler) will snap perpendicularly or tangentialy to any curve that is being snapped to. Two checkboxes have been added to the document properties dialog (on the snapping tab). Please note that snapping perpendicularly or tangetialy will not work in the selector tool when transforming an object or a selection of objects.


Depending on the design, snapping tangentially might not be that precise.
Because the paths themselves differ from a geometrical circle, only nodes can be calculated accurately.
To be honest I only know of a manual guesswork-like way to construct the coincident tagged point in your image, which, will be more accurate than by trying to construct the old fashioned way from two circles.
Or to calculate the coordinates.

That's the dark side of the Bézier.

GeorgeZ
Posts: 6
Joined: Tue Dec 19, 2017 9:39 am

Re: Tangent lines?

Postby GeorgeZ » Tue Dec 19, 2017 9:54 am

I found this post thru a google search, but I did not find an answer to the question.

So I spent some time and wrote an extension for drawing tangent lines from a point to a circle, or tangent lines between two circles.

You need to draw the red dash lines as path, select the path, and choose menu Extensions -> Render -> Draw Rectangle. The extension read the coordinates of points on the auxiliary path and draw the tangent lines.

It is easy to draw the auxiliary path by turning on the "Snap smooth nodes" and "Snap Centers of objects" buttons on snap bar.


[img]g5481.png[/img]

draw-tangent.zip
INX and Py file
(2.38 KiB) Downloaded 332 times
Attachments
g5481.png
g5481.png (55.19 KiB) Viewed 6483 times

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

Re: Tangent lines?

Postby tylerdurden » Tue Dec 19, 2017 12:57 pm

Very nice... thank you!
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/

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

Re: Tangent lines?

Postby brynn » Wed Dec 20, 2017 2:20 pm

You're welcome to upload to the Inkscape website, if you like: https://inkscape.org/en/gallery/=extens ... er=-edited

GeorgeZ
Posts: 6
Joined: Tue Dec 19, 2017 9:39 am

Re: Tangent lines?

Postby GeorgeZ » Tue Jun 26, 2018 9:11 am

June 2018, added code to handle two circles with equal radii. The original version reports an error.


Screenshot_2018-06-25_19-47-25.png
explain
Screenshot_2018-06-25_19-47-25.png (189.3 KiB) Viewed 5592 times


Here is how to use the extension.

1. Draw an auxiliary line from 1 to 2 to 3, or a line from 4 to 5 to 6 to 7.
2. With the line selected, select menu item Extensions > Render > Draw Tangent.
3. Select an option on the popup menu, click apply.

Now the extension can handle two equal radii circles.
Attachments
draw_tangent_1.2.zip
(3.12 KiB) Downloaded 278 times
Last edited by GeorgeZ on Wed Jun 27, 2018 9:34 am, edited 1 time in total.

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

Re: Tangent lines?

Postby Moini » Wed Jun 27, 2018 4:48 am

George, is this already online on the inkscape.org website? If it isn't, please share it there! :)
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)

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

Re: Tangent lines?

Postby ragstian » Wed Jun 27, 2018 8:57 am

Hi

Very Nice !!

"Difficult" to find in the "Render" extension group - might be worth making it's own "CAD_Tools" or something similar?

Might also be useful to catch input errors which now result in "math domain error"?

Nice Code!
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

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

Re: Tangent lines?

Postby theozh » Fri Jul 06, 2018 6:41 am

Thanks, @GeorgeZ for your work. Nice extension.
I would love to see more such geometric and CAD-like functions like this.

Let me just mention:
a) creating a tangent from a point to a circle (or more general any shape) is already implemented in Inkscape :D.
1. go to: File | Document Properties (or Shift+Ctrl+D)
2. go to: Snap tab
3. go to: Miscellaneous, check "Snap perpendicular" and "Snap tangentially"
4. on the "Snap bar" enable snap to path

Tangent_To_Circle.gif
Tangent_To_Circle.gif (96.16 KiB) Viewed 5331 times


b) for those who are interested in creating tangents between arbitrary shaped objects you can use snap tangentially (see a)) and get well approximated tangents as follows:
1.-4. set perpenticular and tangential snapping, see a)
5. start to draw a freehand line (F6) from the approximated (by eye) tangent point of the 1st shape
6. drag and move it to the 2nd shape until it snaps tangentially
7. select node tool (F2) and move the 1st node of the line until it snaps tangentially to the 1st shape
8. select the 2nd node and move it until it snaps tagentially to the 2nd shape
9. repeat step 7. and 8. until the coordinates of the the 1st and 2nd nodes do not change anymore (maybe 2-3 times should be good enough)

More elegant and efficient methods for b) are welcome.
Tangent_To_Shapes.gif
Tangent_To_Shapes.gif (205.76 KiB) Viewed 5331 times
Win7/64, Inkscape 0.92.2

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Tangent lines?

Postby druban » Thu Jul 12, 2018 4:41 pm

A very limited in application method - which is to say it has drawing utility but no mathematical rigor* - is to select both objects, display the bounding box and start rotating until both objects are touching one side of the bounding box. Now draw a horizontal or vertical line snap it to the bounding box and then rotate all back to where they were before. Make sense?

*Okay, so if you really want to get into the calculus it has some mathematical rigor since the tangent and its perpendicular define a rotated coordinate plane etc. but really who wants to go there
Your mind is what you think it is.

orobinec
Posts: 1
Joined: Sun Jul 14, 2019 7:45 pm

Re: Tangent lines?

Postby orobinec » Sun Jul 14, 2019 7:47 pm

GeorgeZ, does your extension work for you on 0.92.4? I wanted to try it, but sadly I was unsuccessful…

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

Re: Tangent lines?

Postby Moini » Mon Jul 15, 2019 3:21 am

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)


Return to “Help with using Inkscape”