C#或VB开发ArcGIS Engine根据三角形的顶点坐标提取三角形的一条中线,求高手指教,万分感谢!!! 5
展开全部
List<IPoint> pList = new List<IPoint>(); //// 三个顶点
IPoint pMidPoint = new PointClass(); //// 对边中点
IPoint pFirst=pList[0]; //// 取一个顶点
IPolyline pLine = new PolylineClass(); //// 中线
double X = (pList[1].X + pList[2].X)/2;
double Y =( pList[1].Y + pList[2].Y)/2;
pMidPoint.PutCoords(X,Y);
(pMidPoint as IGeometry).SpatialReference = (pFirst as IGeometry).SpatialReference;
object before = Type.Missing;
object after = Type.Missing;
(pLine as IPointCollection).AddPoint(pFirst,ref before,ref after);
(pLine as IPointCollection).AddPoint(pMidPoint, ref before, ref after);
IPoint pMidPoint = new PointClass(); //// 对边中点
IPoint pFirst=pList[0]; //// 取一个顶点
IPolyline pLine = new PolylineClass(); //// 中线
double X = (pList[1].X + pList[2].X)/2;
double Y =( pList[1].Y + pList[2].Y)/2;
pMidPoint.PutCoords(X,Y);
(pMidPoint as IGeometry).SpatialReference = (pFirst as IGeometry).SpatialReference;
object before = Type.Missing;
object after = Type.Missing;
(pLine as IPointCollection).AddPoint(pFirst,ref before,ref after);
(pLine as IPointCollection).AddPoint(pMidPoint, ref before, ref after);
更多追问追答
追问
非常感谢您的帮助。我之前在Arcgis上画了一个三角形polygon,并且提取了三个顶点的坐标,在其属性表里分别存了X0,X1,X2,X3,其中X0和X3是同一点,我将这个点和面图层添加到mapcontrol,然后运行您提供的代码,没有画出来中线,想向您请教。
追答
你要展示我所构造的中线 你必须再构造一个元素或者要素添加到地图才能显示
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询