[Extension] inkTan - draw tangent lines between two circles

Other sites and resources for Inkscape users.
rhysun
Posts: 6
Joined: Fri Feb 24, 2012 5:32 am
Location: Cymru / Wales

[Extension] inkTan - draw tangent lines between two circles

Postby rhysun » Sat Aug 29, 2015 10:04 am

This is an extension I wrote some years ago for drawing tangent lines between two circles. I re-discovered it a few days ago whilst looking through the hdd from my old computer (RIP). The comments and some of the variable names in the code are in Welsh - but I shall translate them if anyone is interested. It is a bit clunky but it seems to work most of the time. If anyone finds this extension useful I shall revisit the code and give it a bit of a tidy-up and maybe some documentation. Find the files in my GitHub https://github.com/Rhysun/inkTan.git

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

Re: [Extension] inkTan - draw tangent lines between two circ

Postby brynn » Sat Aug 29, 2015 12:22 pm

I'm pretty sure I know what a tangent line between 2 circles is. But I'm curious how the extension works. How can I install it? Do I just put the INX and the PY file in the share/attachments folder? Or do I need to do something with those other 2 files?

rhysun
Posts: 6
Joined: Fri Feb 24, 2012 5:32 am
Location: Cymru / Wales

Re: [Extension] inkTan - draw tangent lines between two circ

Postby rhysun » Sat Aug 29, 2015 5:03 pm

Yes, you just need the INX and the PY and drop them in the share/extensions folder - the other two files are just some GIT stuff and should be ignored (unless you would like to make a fork ;-) ). Then select two circles (not ellipses) and 'Tangent...' should appear in the Extensions / Render menu. The tangent lines will adopt the same stroke as one of the circles, so if they are drawn without a stroke the lines will be invisible. I hope this helps - I intend to make some proper documentation in due course!
Last edited by rhysun on Sat Aug 29, 2015 8:41 pm, edited 1 time in total.

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

Re: [Extension] inkTan - draw tangent lines between two circ

Postby brynn » Sat Aug 29, 2015 5:57 pm

Oh, I see. Very nice!

Now that I see it, I may remember when you first made it....at least I remember several years ago some messages about how to draw that.

I expected it would draw just 1 tangent line, from your description. But it actually draws 2 -- like a belt around 2 wheels or gears. Or like an orbit around 2 planets.....or more like the path of a spaceship, than the orbit of the planets. And I wondered which side of the circles it would "connect". But there are options for either way.

Nice!

I wonder if it could be made to draw tangent lines to any kind of object? Welll....I suppose the notion of tangency really does only apply to circles....or at least curves. Couldn't you have a line tangent to 2 bezier curves? Or the spirals from the Spiral tool? Or any ellipse? I guess that probably gets into much more complex math though, wouldn't it?

I wonder if it would work on 3 circles? Nope, gives an error.

Well anyway, for feedback -- It works very well for me, at least in a new blank document (Inks 0.91, 32-bit, Windows 7, 64-bit). I've found a lot of extensions fail in a large file (over 1 or 2 mb) so I haven't tested that way yet. I could also test in 0.91, 64-bit and 0.48.5, if it would be helpful.

I have no expertise to be able to analyze or give feedback on the code.

I'm sure a plenty of people would find this useful!

Oh hey....I've been trying to find someone who could and would write a tutorial for how to create extensions (https://inkscape.org/en/contribute/to-do-list/). Just in case you're interested (or anyone reading this might be) ;)

Also, I'm working on a project to have all extensions which don't come packed with Inkscape, listed on the Inkscape website. At the moment, they are scattered here and there around the internet, and most people can't find them, unless they are super persistent about searching. I'll be happy to list this one, and I'll save the GH link, for that purpose.

But it would be helpful if, in the meantime, you could have it listed on the wiki Extensions Repository page http://wiki.inkscape.org/wiki/index.php ... y#InkLaTeX. You can get wiki edits creds by requesting it on the dev mailing list https://inkscape.org/en/community/mailing-lists/. Or if you could possibly get it on this page, although I'm not exactly s ure how to do that....actually that page probably isn't ready for a lot of extension writers to use it yet. I could probably add it to the wiki page myself, if you like.

rhysun
Posts: 6
Joined: Fri Feb 24, 2012 5:32 am
Location: Cymru / Wales

Re: [Extension] inkTan - draw tangent lines between two circ

Postby rhysun » Sat Aug 29, 2015 6:53 pm

Thanks brynn - I will do those things. I am going camping with the kids right now so it will be a few days before I do anything. Tangent lines between irregular objects would be nice but probably complicated to code, I'm sure I've seen it done in some CAD application once. But where there's a will there's a way. There is a way to snap tangentially in Inkscape but only from a pre-selected point. It needs to be activated per document - (File - Document Properties - Snap) it's a checkbox down at the bottom of the tab.

A tip: if you combine the two lines (Path - Combine) you can join the adjacent end nodes with a new segment to make a quadrilateral. You can then make an union (Path - Union) from the quadrilateral and the two circles.

If you need, let say, a triangle with rounded points, draw three circles, render the tangent lines (two circles at a time). Then delete the unwanted (inner) lines. Then with the three remaining lines, combine, make new segments between adjacent end nodes to make a hexagon. Then make an union between the hexagon and the three circles.


Return to “Inkscape Resources”