2d path "shrink-wrap" algorithms

1.2k Views Asked by At

Suppose we are given some 2d path geometry. Is there an algorithm that could produce a new path that "wraps" the geometry in a similar form as below?

Original path = GREY. New path = RED

The effect should be similar to how an object looks when it is shrink-wrapped. Thanks in advance

1

There are 1 best solutions below

0
Reblochon Masque On

You could try using quadratic splines with anchors at the vertices at the start of a concave area, and a control point at a location inside the concave area.

The control point location will have to be determined based on the local geometry.

something like this, maybe?

enter image description here

The algorithm could be:

1- find the convex hull  
2- for each concave segment (where the convex hull doesn't match the polygon path):  
    2a - id the start and end point as anchors  
    2b - id a control point position
    2c - trace a quadratic spline using these points