ArcGIS Pro SDK (九)几何 9 立方贝塞尔线段

环境:Visual Studio 2022 + .NET6 + ArcGIS Pro SDK 3.0

1 构建立方贝塞尔线段 - 从坐标

// 使用 builderEx 的便捷方法或使用 builderEx 构造函数。

MapPoint startPt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0, 3.0);
MapPoint endPt = MapPointBuilderEx.CreateMapPoint(2.0, 2.0, 3.0);

Coordinate2D ctrl1Pt = new Coordinate2D(1.0, 2.0);
Coordinate2D ctrl2Pt = new Coordinate2D(2.0, 1.0);

// BuilderEx 的便捷方法不需要在 MCT 上运行
CubicBezierSegment bezier = CubicBezierBuilderEx.CreateCubicBezierSegment(startPt, ctrl1Pt, ctrl2Pt, endPt, SpatialReferences.WGS84);

// 不使用空间参考系
bezier = CubicBezierBuilderEx.CreateCubicBezierSegment(startPt, ctrl1Pt, ctrl2Pt, endPt);


// builderEx 的构造函数不需要在 MCT 上运行
CubicBezierBuilderEx cbbEx = new CubicBezierBuilderEx(startPt, ctrl1Pt, ctrl2Pt, endPt);
bezier = cbbEx.ToSegment() as CubicBezierSegment;

// 另一种方式
cbbEx = new CubicBezierBuilderEx(startPt, ctrl1Pt.ToMapPoint(), ctrl2Pt.ToMapPoint(), endPt);
bezier = cbbEx.ToSegment() as CubicBezierSegment;

2 构建立方贝塞尔线段 - 从地图点

// 使用 builderEx 的便捷方法或使用 builderEx 构造函数。

MapPoint startPt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84);
MapPoint endPt = MapPointBuilderEx.CreateMapPoint(2.0, 2.0, SpatialReferences.WGS84);

MapPoint ctrl1Pt = MapPointBuilderEx.CreateMapPoint(1.0, 2.0, SpatialReferences.WGS84);
MapPoint ctrl2Pt = MapPointBuilderEx.CreateMapPoint(2.0, 1.0, SpatialReferences.WGS84);

// BuilderEx 的便捷方法不需要在 MCT 上运行
CubicBezierSegment bezier = CubicBezierBuilderEx.CreateCubicBezierSegment(startPt, ctrl1Pt, ctrl2Pt, endPt);

// builderEx 的构造函数不需要在 MCT 上运行
CubicBezierBuilderEx cbbEx = new CubicBezierBuilderEx(startPt, ctrl1Pt, ctrl2Pt, endPt);
bezier = cbbEx.ToSegment() as CubicBezierSegment;

3 构造立方贝塞尔线段 - 从映射点的枚举

// 使用 builderEx 的便捷方法或使用 builderEx 构造函数。

MapPoint startPt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84);
MapPoint endPt = MapPointBuilderEx.CreateMapPoint(2.0, 2.0, SpatialReferences.WGS84);

MapPoint ctrl1Pt = MapPointBuilderEx.CreateMapPoint(1.0, 2.0, SpatialReferences.WGS84);
MapPoint ctrl2Pt = MapPointBuilderEx.CreateMapPoint(2.0, 1.0, SpatialReferences.WGS84);

List<MapPoint> listMapPoints = new List<MapPoint>();
listMapPoints.Add(startPt);
listMapPoints.Add(ctrl1Pt);
listMapPoints.Add(ctrl2Pt);
listMapPoints.Add(endPt);

// BuilderEx 的便捷方法不需要在 MCT 上运行
CubicBezierSegment bezier = CubicBezierBuilderEx.CreateCubicBezierSegment(listMapPoints);

// builderEx 的构造函数不需要在 MCT 上运行
CubicBezierBuilderEx cbbEx = new CubicBezierBuilderEx(listMapPoints);
bezier = cbbEx.ToSegment() as CubicBezierSegment;

4 立方贝塞尔线段生成器属性

// 获取贝塞尔曲线的控制点

CubicBezierBuilderEx cbbEx = new CubicBezierBuilderEx(bezierSegment);
MapPoint startPtEx = cbbEx.StartPoint;
Coordinate2D ctrlPt1Ex = cbbEx.ControlPoint1;
Coordinate2D ctrlPt2Ex = cbbEx.ControlPoint2;
MapPoint endPtEx = cbbEx.EndPoint;
     
// 或使用 QueryCoords 方法
cbbEx.QueryCoords(out startPtEx, out ctrlPt1Ex, out ctrlPt2Ex, out endPtEx);

5 立方贝塞尔线段属性

// 获取贝塞尔曲线的控制点
CubicBezierSegment cb = CubicBezierBuilderEx.CreateCubicBezierSegment(bezierSegment);
MapPoint startPt = cb.StartPoint;
Coordinate2D ctrlPt1 = cb.ControlPoint1;
Coordinate2D ctrlPt2 = cb.ControlPoint2;
MapPoint endPt = cb.EndPoint;

bool isCurve = cb.IsCurve;
double len = cb.Length;

6 构造折线 - 从立方贝塞尔线段

Polyline polyline = PolylineBuilderEx.CreatePolyline(bezierSegment);

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部