介绍
通过用三次贝塞尔曲线替换输入的线段来创建弯曲几何体。
Creates a curved geometry by replacing the segments of the input with Cubic Bezier Curves.
注意:
贝塞尔控制点由几何体的分段和控制曲率的alpha
控制参数以及控制顶点处曲线形状的可选斜交参数skew
确定。贝塞尔曲线在每个输入顶点处被创建为C2(C2-continuous
)连续(平滑)。
此外,也可以明确地提供贝塞尔控制点。
生成的结果不能保证有效,因为较大的alpha值可能会导致自交。
The Bezier control points are determined from the segments of the geometry and the alpha control parameter controlling curvedness, and the optional skew parameter controlling the shape of the curve at vertices. The Bezier Curves are created to be C2-continuous (smooth) at each input vertex.
Alternatively, the Bezier control points can be supplied explicitly.
The result is not guaranteed to be valid, since large alpha values may cause self-intersections.
方法1
方法2
示例
在NuGet中安装2.x
版本的NetTopologySuite,示例代码:
var wkt = "linestring(0 0,1 0, 2 0,3 1,4 1,5 1,6 -1,7 -1,8 -1)";
var r = new WKTReader();
var g = r.Read(wkt);
var g0 = CubicBezierCurve.Create(g, 0);
var g1 = CubicBezierCurve.Create(g, 0.5);
var g2 = CubicBezierCurve.Create(g, 1);
var g3 = CubicBezierCurve.Create(g, 1.5);
var geos = new Geometry[] { g0, g1, g2, g3 };
//保存生成的结果为图形
//Save("./TmpShp/pts.shp", g.Coordinates.Select(x=>new Point(x)).ToArray());
//Save("./TmpShp/g0.shp", g0);
//Save("./TmpShp/g1.shp", g1);
//Save("./TmpShp/g2.shp", g2);
//Save("./TmpShp/g3.shp", g3);
效果图:
- 输入的原始数据是一条折线LineString(其中折点被高亮了,为了方便看效果)
当alpha参数=0时,生成的结果和输入的数据相同。
- 当alpha参数=0.5时
3. 当alpha参数=1时
4. 当alpha参数=1.5时
叠加原始数据: