ArcGIS Pro SDK (九)几何 2 坐标
 
 
 
 
文章目录
 
  
 
 
 
1 矢量极坐标
 
Coordinate3D polarVector = new Coordinate3D(0, 7, 0);
Tuple<double, double, double> polarComponents = polarVector.QueryPolarComponents();
polarVector.SetPolarComponents(Math.PI / 4, Math.PI / 2, 8);
polarComponents = polarVector.QueryComponents();
 
2 获取矢量倾角
 
Coordinate3D v = new Coordinate3D(0, 0, 7);
double inclination = v.Inclination;         
v.SetComponents(-2, -3, 0);
inclination = v.Inclination;                
v.SetComponents(0, 0, -2);
inclination = v.Inclination;                
 
3 获取矢量方位角
 
Coordinate3D vector = new Coordinate3D(0, 7, 0);
double azimuth = vector.Azimuth;      
vector.SetComponents(1, 1, 42);
azimuth = vector.Azimuth;
double degrees = AngularUnit.Degrees.ConvertFromRadians(azimuth);       
vector.SetComponents(-8, 8, 2);
azimuth = vector.Azimuth;
degrees = AngularUnit.Degrees.ConvertFromRadians(azimuth);              
 
4 向量运算
 
Coordinate3D v = new Coordinate3D(0, 1, 0);
Coordinate3D other = new Coordinate3D(-1, 0, 0);
double dotProduct = v.DotProduct(other);      
Coordinate3D crossProduct = v.CrossProduct(other);
Coordinate3D addVector = v.AddCoordinate3D(other);
Coordinate3D w = v;
w.Rotate(Math.PI, other);
w.Scale(0.5);
w.Scale(-4);
w.Move(3, 2, 0);
Coordinate3D emptyVector = new Coordinate3D();
emptyVector.SetEmpty();
Coordinate3D c1 = new Coordinate3D(2, 3, 4);
Coordinate3D c2 = new Coordinate3D(9, -1, 3);
var result_add = c1 + c2;
var result_sub = c1 - c2;
var b = result_sub != result_add;
result_add = emptyVector + c1;
b = result_add == emptyVector;
 
5 2D 矢量操作
 
Coordinate2D v = new Coordinate2D(0, 1);
Coordinate2D other = new Coordinate2D(-1, 0);
double dotProduct = v.DotProduct(other);
Coordinate2D w = v + other;
w += other;
w -= other;
w = v;
w.Rotate(Math.PI, other);
w = other;
w.Scale(-4);
w.Move(-1, 4);
w.Move(-6, -1);
Tuple<double, double> components = w.QueryComponents();
Coordinate2D unitVector = w.GetUnitVector();
w.SetComponents(3, 4);
 
6 生成器
 
List<MapPoint> points = new List<MapPoint>
{
  MapPointBuilderEx.CreateMapPoint(0, 0, 2, 3, 1),
  MapPointBuilderEx.CreateMapPoint(1, 1, 5, 6),
  MapPointBuilderEx.CreateMapPoint(2, 1, 6),
  MapPointBuilderEx.CreateMapPoint(0, 0)
};
Polyline polylineWithAttrs = PolylineBuilderEx.CreatePolyline(points);
bool hasZ = polylineWithAttrs.HasZ;          
bool hasM = polylineWithAttrs.HasM;          
bool hasID = polylineWithAttrs.HasID;        
Polyline polylineWithoutAttrs = 
  PolylineBuilderEx.CreatePolyline(points, AttributeFlags.None);
hasZ = polylineWithoutAttrs.HasZ;          
hasM = polylineWithoutAttrs.HasM;          
hasID = polylineWithoutAttrs.HasID;        
Polygon polygonWithAttrs = PolygonBuilderEx.CreatePolygon(points);
hasZ = polygonWithAttrs.HasZ;               
hasM = polygonWithAttrs.HasM;               
hasID = polygonWithAttrs.HasID;             
Polygon polygonWithoutAttrs = 
      PolygonBuilderEx.CreatePolygon(points, AttributeFlags.None);
hasZ = polygonWithoutAttrs.HasZ;               
hasM = polygonWithoutAttrs.HasM;               
hasID = polygonWithoutAttrs.HasID;             
PolylineBuilderEx polylineB = 
           new PolylineBuilderEx(points, AttributeFlags.None);
hasZ = polylineB.HasZ;                      
hasM = polylineB.HasM;                      
hasID = polylineB.HasID;                    
polylineB = new PolylineBuilderEx(polylineWithAttrs);
hasZ = polylineB.HasZ;                      
hasM = polylineB.HasM;                      
hasID = polylineB.HasID;                    
polylineB = new PolylineBuilderEx(polylineWithoutAttrs);
hasZ = polylineB.HasZ;                      
hasM = polylineB.HasM;                      
hasID = polylineB.HasID;                    
PolygonBuilderEx polygonB = new PolygonBuilderEx(points, AttributeFlags.None);
hasZ = polygonB.HasZ;                       
hasM = polygonB.HasM;                       
hasID = polygonB.HasID;                     
polygonB = new PolygonBuilderEx(polygonWithAttrs);
hasZ = polygonB.HasZ;                       
hasM = polygonB.HasM;                       
hasID = polygonB.HasID;                     
polygonB = new PolygonBuilderEx(polygonWithoutAttrs);
hasZ = polygonB.HasZ;                       
hasM = polygonB.HasM;                       
hasID = polygonB.HasID;