二维路径“收缩包装”算法

Tom*_*awa 1 algorithm geometry 2d shrinkwrap

假设我们有一些二维路径几何。是否有一种算法可以生成一条新路径,以如下类似的形式“包裹”几何图形?

原始路径 = 灰色。 新路径 = 红色

效果应该类似于对象收缩包装时的外观。提前致谢

Reb*_*que 5

您可以尝试使用二次样条曲线,在凹面区域开始的顶点处使用锚点,并在凹面区域内的某个位置使用控制点。

控制点位置必须根据局部几何形状确定。

像这样的,也许?

在此处输入图片说明

该算法可以是:

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
Run Code Online (Sandbox Code Playgroud)