0

I want to take a path that is curved and is concave in some parts, and generate a convex path that keeps the curvature of the original. I don't want a bounding box or polygon, it needs to essentially mask the original.

This image should make it clearer. I want to go from one of the options on the left to the path on the right. enter image description here

I'm hoping to do this in Inkscape, as it fits my workflow, but I'm willing to use something else if necessary.

2
  • And what do you expect? inkscape to do this automatically for you? Inkscape is a drawing program just draw the tangents yourself.
    – joojaa
    Commented Jul 13 at 4:09
  • You can use the rectangle tool in Inkscape to draw a rectangle and then round its corners to make the ends semi-circular, creating a pill shape.
    – Billy Kerr
    Commented Jul 13 at 8:20

1 Answer 1

0

I guess your actual shape is more complex and you are not going to accept anything which suggests drawing the shown shape directly or combining with a rectangle.

Here's one manual method.

enter image description here

In the left there's 2 circles which are combined to one with Path > Union.

  1. Deselect all
  2. Click the shape with the node tool
  3. Select with the node tool those 2 nodes which are inside the red curve. Click+Hold shift or drag over the marked nodes to select both nodes for node operations. Select nothing else
  4. Press DEL and get the shape in the right

This works only in cases where the other nodes have the handles directed so that they form a convex shape. It will not work if you delete 2 nodes from the next version:

enter image description here

You must at first insert (double-click with the node tool) new nodes to 12 and 6 o'clock positions and then delete all nodes in the concave area. As well you could draw with the pen the missing pieces (it's only clicking, because you need only straight path segments) and make a path union. How to make the lines is shown in the end of this answer.

A programmer maybe could create an automatic method. I have never seen such function available in 2D drawing programs, but it can exist. Website Stack Overflow contains discussions of the problem and they have links to other sites where some actual code is presented. It's here off-topic. Here's one Stack Overflow discussion https://stackoverflow.com/questions/3208515/whats-an-easy-way-to-fill-a-concave-pathgeometry-to-be-convex-finding-the-conca

An answer in the linked discussion leads to an attempt to solve the problem by making something which imitates in 2D shrink wrapping or tightening a rope loop. It's not complete, because it works only with polygons.

I'm afraid making a working automatic program would be far beyond the skills of a casual programmer. But the idea is in Inkscape easily applicable to manual work, because Inkcape has well working (and much wanted) node snap option "Tangential Line". It's used in the next example:

enter image description here

In the left a polygon is drawn around the black shape. The number of nodes can be easily reduced or increased afterwards, if needed.

In the middle the nodes are moved with the node tool to get the tangential line snap indication. Unnecessary nodes are moved inside the black shape.The tangency harmfully isn't true at the other end of the line any more if one end is moved. For that reason you must walk around the shape several times and iterate the places of the nodes to be sure the result will be close enough the perfect one.

In the right the shapes are combined by applying Path > Union.

ADD: There's a comment (by user joojaa) which suggest to use an Illustrator add-on script, which makes the tangency true at both ends of a line. But that add-on is for Illustrator.

2
  • I have seen one though that comes close. Hiruoki sato has made a illistrator script that finds all common tangents between shapes what this does is it makes a outer shape that is entirely convex, if the subparts do not contain hard edges. Just that it has a lot of extra edges but thats what the shapebuilding tools are for.
    – joojaa
    Commented Jul 13 at 22:04
  • Thanks, the second part about manually getting the tangent lines worked perfectly. I was unaware of those features of InkScape. I did not mean to imply an automatic solution was necessary, this works well for my workflow. Commented Aug 9 at 3:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.