ArcGIS Pro SDK (九)几何 10 弧

ArcGIS Pro SDK (九)几何 10 弧

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

1 构造圆弧 - 使用内部点

// 从 (2, 1) 到 (1, 2) 构造圆弧,内部点为 (1 + sqrt(2)/2, 1 + sqrt(2)/2)。
// 使用 builderEx 的便捷方法或使用 builderEx 构造函数。

MapPoint fromPt = MapPointBuilderEx.CreateMapPoint(2, 1);
MapPoint toPt = MapPointBuilderEx.CreateMapPoint(1, 2);
Coordinate2D interiorPt = new Coordinate2D(1 + Math.Sqrt(2) / 2, 1 + Math.Sqrt(2) / 2);

// BuilderEx 的便捷方法不需要在 MCT 上运行。
EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateCircularArc(fromPt, toPt, interiorPt);

// BuilderEx 的构造函数不需要在 MCT 上运行。
EllipticArcBuilderEx eab = new EllipticArcBuilderEx(fromPt, toPt, interiorPt);
// 使用生成器执行操作

EllipticArcSegment anotherCircularArc = eab.ToSegment();

2 构造圆弧 - 使用弦长度和方位

// Construct a circular arc counterclockwise from (2, 1) to (1, 2) such that the embedded 
// circle has center point at (1, 1) and radius = 1.
// Use a builderEx convenience method or use a builderEx constructor.

MapPoint fromPt = MapPointBuilderEx.CreateMapPoint(2, 1, SpatialReferences.WGS84);
double chordLength = Math.Sqrt(2);
double chordBearing = 3 * Math.PI / 4;
double radius = 1;
ArcOrientation orientation = ArcOrientation.ArcCounterClockwise;
MinorOrMajor minorOrMajor = MinorOrMajor.Minor;

// BuildeExr convenience methods don't need to run on the MCT.
EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateCircularArc(fromPt, chordLength, chordBearing, radius, orientation, minorOrMajor);

// BuilderEx constructors need to run on the MCT.
EllipticArcBuilderEx cab = new EllipticArcBuilderEx(fromPt, chordLength, chordBearing, radius, orientation, minorOrMajor);
// do something with the builder

EllipticArcSegment anotherCircularArc = cab.ToSegment();

3 构建圆弧 - 使用中心点、角度和半径

// 构造一个圆弧,中心点在 (0, 0),起始角度为 0,中心角为 pi/2,半径为 1。
// 使用 builderEx 的便捷方法或使用 builderEx 构造函数。

SpatialReference sr4326 = SpatialReferences.WGS84;
Coordinate2D centerPt = new Coordinate2D(0, 0);
double fromAngle = 0;
double centralAngle = Math.PI / 2;
double radius = 1;

// BuilderEx 的便捷方法不需要在 MCT 上运行。
EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateCircularArc(fromAngle, centralAngle, centerPt, radius, sr4326);

// BuilderEx 的构造函数不需要在 MCT 上运行。
EllipticArcBuilderEx cab = new EllipticArcBuilderEx(fromAngle, centralAngle, centerPt, radius, sr4326);
EllipticArcSegment otherCircularArc = cab.ToSegment();

4 构造椭圆弧 - 使用中心点和旋转角度

// 构造一个中心在 (1, 1) 的椭圆弧,起始角度为 0,中心角为 PI/2,旋转角为 0,半长轴为 1,短长轴比为 0.5。
// 使用 builderEx 的便捷方法或使用 builderEx 构造函数。

Coordinate2D centerPt = new Coordinate2D(1, 1);

// BuilderEx 的便捷方法不需要在 MCT 上运行。
EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateEllipticArcSegment(centerPt, 0, Math.PI / 2, 0, 1, 0.5);

double semiMajor;
double semiMinor;
circularArc.GetAxes(out semiMajor, out semiMinor);
// semiMajor = 1, semiMinor = 0.5

// BuilderEx 的构造函数不需要在 MCT 上运行。
EllipticArcBuilderEx cab = new EllipticArcBuilderEx(centerPt, 0, Math.PI / 2, 0, 1, 0.5);
cab.GetAxes(out semiMajor, out semiMinor);
EllipticArcSegment otherCircularArc = cab.ToSegment();

5 构造圆弧 - 使用中心点和方向

// 从 (2, 1) 到 (1, 2) 构造一个圆弧,中心点在 (1, 1),方向为逆时针。
// 使用 builderEx 的便捷方法或使用 builderEx 构造函数。

MapPoint toPt = MapPointBuilderEx.CreateMapPoint(1, 2);
MapPoint fromPt = MapPointBuilderEx.CreateMapPoint(2, 1);
Coordinate2D centerPtCoord = new Coordinate2D(1, 1);

// BuilderEx 的便捷方法不需要在 MCT 上运行。
EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateCircularArc(fromPt, toPt, centerPtCoord, ArcOrientation.ArcCounterClockwise);

// BuilderEx 的构造函数需要在 MCT 上运行。
EllipticArcBuilderEx cab = new EllipticArcBuilderEx(fromPt, toPt, centerPtCoord, ArcOrientation.ArcCounterClockwise);
EllipticArcSegment otherCircularArc = cab.ToSegment();

6 构造圆弧 - 使用两个线段和半径

// 从 (100, 100) 到 (50, 50) 构造一条线段,另一条线段从 (100, 100) 到 (150, 50)。
// 使用 builderEx 的便捷方法或使用 builderEx 构造函数。

LineSegment segment1 = LineBuilderEx.CreateLineSegment(new Coordinate2D(100, 100), new Coordinate2D(50, 50));
LineSegment segment2 = LineBuilderEx.CreateLineSegment(new Coordinate2D(100, 100), new Coordinate2D(150, 50));

// 构造提示点以确定圆弧将在哪里构造。
Coordinate2D hintPoint = new Coordinate2D(100, 75);

// 调用 QueryFilletRadius 以获取可与这些线段一起使用的最小和最大半径。
var minMaxRadii = EllipticArcBuilderEx.QueryFilletRadiusRange(segment1, segment2, hintPoint);

// 使用最大半径创建圆弧。
double maxRadius = minMaxRadii.Item2;

// BuilderEx 的便捷方法不需要在 MCT 上运行。
// 在 2.x 版本中 - EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateEllipticArcSegment(segment1, segment2, maxRadius, hintPoint);
EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateCircularArc(
                    segment1, segment2, maxRadius, hintPoint);

// BuilderEx 的构造函数需要在 MCT 上运行。
EllipticArcBuilderEx cab = new EllipticArcBuilderEx(segment1, segment2, maxRadius, hintPoint);
EllipticArcSegment otherCircularArc = cab.ToSegment();

7 构造圆

// 构造一个圆,中心在 (-1,-1),半径为 2,方向为顺时针。
// 使用 builderEx 的便捷方法或使用 builderEx 构造函数。

Coordinate2D centerPtCoord = new Coordinate2D(-1, -1);

// Builder 便捷方法不需要在 MCT 上运行。
EllipticArcSegment circle = EllipticArcBuilderEx.CreateCircle(centerPtCoord, 2, ArcOrientation.ArcClockwise);
// circle.IsCircular = true
// circle.IsCounterClockwise = false
// circle.IsMinor = false

double startAngle, rotationAngle, centralAngle, semiMajor, semiMinor;
Coordinate2D actualCenterPt;
circle.QueryCoords(out actualCenterPt, out startAngle, out centralAngle, out rotationAngle, out semiMajor, out semiMinor);

// semiMajor = 2.0
// semiMinor = 2.0
// startAngle = PI/2
// centralAngle = -2*PI
// rotationAngle = 0
// endAngle = PI/2

// BuilderEx 的构造函数需要在 MCT 上运行。
EllipticArcBuilderEx builder = new EllipticArcBuilderEx(centerPtCoord, 2, ArcOrientation.ArcClockwise);
EllipticArcSegment otherCircle = builder.ToSegment();

8 构造椭圆

// 构造一个中心在 (1, 2) 的椭圆,旋转角为 -pi/6,半长轴为 5,短长轴比为 0.2,方向为顺时针。
// 使用 builderEx 的便捷方法或使用 builderEx 构造函数。

Coordinate2D centerPt = new Coordinate2D(1, 2);

// BuilderEx 的便捷方法不需要在 MCT 上运行。
EllipticArcSegment ellipse = EllipticArcBuilderEx.CreateEllipse(centerPt, -1 * Math.PI / 6, 5, 0.2, ArcOrientation.ArcClockwise);

// BuilderEx 的构造函数需要在 MCT 上运行。
EllipticArcBuilderEx builder = new EllipticArcBuilderEx(centerPt, -1 * Math.PI / 6, 5, 0.2, ArcOrientation.ArcClockwise);
EllipticArcSegment anotherEllipse = builder.ToSegment();

9 椭圆构建器属性

// 获取曲线的属性
EllipticArcBuilderEx builder = new EllipticArcBuilderEx(arcSegment);
MapPoint startPt = builder.StartPoint;
MapPoint endPt = builder.EndPoint;
Coordinate2D centerPt = builder.CenterPoint;
bool isCircular = builder.IsCircular;
bool isMinor = builder.IsMinor;
double startAngle = builder.StartAngle;
double endAngle = builder.EndAngle;
double centralAngle = builder.CentralAngle;
double rotationAngle = builder.RotationAngle;
ArcOrientation orientation = builder.Orientation;

10 椭圆弧属性

// 获取曲线的控制点
EllipticArcSegment arc = EllipticArcBuilderEx.CreateEllipticArcSegment(arcSegment);
MapPoint startPt = arc.StartPoint;
MapPoint endPt = arc.EndPoint;
Coordinate2D centerPt = arc.CenterPoint;
bool isCircular = arc.IsCircular;
bool isMinor = arc.IsMinor;
bool isCounterClockwise = arc.IsCounterClockwise;
bool isCurve = arc.IsCurve;
double len = arc.Length;
double ratio = arc.MinorMajorRatio;

double semiMajorAxis, semiMinorAxis;
// 获取轴
arc.GetAxes(out semiMajorAxis, out semiMinorAxis);
// 或者使用属性
// semiMajorAxis = arc.SemiMajorAxis;
// semiMinorAxis = arc.SemiMinorAxis;

double startAngle, centralAngle, rotationAngle;
// 或者使用 QueryCoords 获取完整信息
arc.QueryCoords(out centerPt, out startAngle, out centralAngle, out rotationAngle, out semiMajorAxis, out semiMinorAxis);

// 使用属性获取角度信息
// double endAngle = arc.EndAngle;
// centralAngle = arc.CentralAngle;
// rotationAngle = arc.RotationAngle;
// startAngle = arc.StartAngle;

相关推荐

  1. ArcGIS Pro SDK (几何 10

    2024-07-20 13:48:03       24 阅读
  2. ArcGIS Pro SDK (几何 11 几何

    2024-07-20 13:48:03       22 阅读
  3. ArcGIS Pro SDK (几何 12 多面体

    2024-07-20 13:48:03       21 阅读
  4. ArcGIS Pro SDK (几何 2 坐标

    2024-07-20 13:48:03       24 阅读
  5. ArcGIS Pro SDK (几何 3 点

    2024-07-20 13:48:03       23 阅读
  6. ArcGIS Pro SDK (几何 4 折线

    2024-07-20 13:48:03       26 阅读
  7. ArcGIS Pro SDK (几何 5 多边形

    2024-07-20 13:48:03       25 阅读
  8. ArcGIS Pro SDK (几何 8 线段

    2024-07-20 13:48:03       21 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-20 13:48:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-20 13:48:03       102 阅读
  3. 在Django里面运行非项目文件

    2024-07-20 13:48:03       83 阅读
  4. Python语言-面向对象

    2024-07-20 13:48:03       92 阅读

热门阅读

  1. AB测试介绍

    2024-07-20 13:48:03       23 阅读
  2. MULESOFT

    MULESOFT

    2024-07-20 13:48:03      28 阅读
  3. libevent的事件分发相关接口

    2024-07-20 13:48:03       27 阅读
  4. 082、Python 读文本文件

    2024-07-20 13:48:03       27 阅读
  5. Linux绑定硬件IRQ到指定CPU核

    2024-07-20 13:48:03       25 阅读
  6. 使用内网穿透工具 frp 发布内网 web 站点

    2024-07-20 13:48:03       28 阅读
  7. 【WebRTC】Duplex通信是什么意思?

    2024-07-20 13:48:03       28 阅读
  8. TCP Socket编程示例

    2024-07-20 13:48:03       25 阅读
  9. windows上安装Apache

    2024-07-20 13:48:03       23 阅读