博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
提取面狭长角
阅读量:4302 次
发布时间:2019-05-27

本文共 2278 字,大约阅读时间需要 7 分钟。

private void PRV_CheckSliver(IFeatureClass IN_Featureclass)        {            List
Temp_AllError = new List
();//记录所有错误OID //提取所有要素 IFeatureCursor Temp_GetEachFeature = IN_Featureclass.Search(null, true); IFeature Temp_EachFeature = Temp_GetEachFeature.NextFeature(); if (Temp_EachFeature != null) { //尽量不在循环中创建变量 IPointCollection Temp_Vertices; IPoint First_Point = new Point(); IPoint Center_Point = new Point(); IPoint Last_Point = new Point(); int i; //将错误的OID提到List里 while (Temp_EachFeature != null) { //获取要素的点集 Temp_Vertices = Temp_EachFeature.Shape as IPointCollection; Temp_Vertices.AddPoint(Temp_Vertices.get_Point(1)); for (i = 0; i < Temp_Vertices.PointCount - 3; i++) { Temp_Vertices.QueryPoint(i, First_Point); Temp_Vertices.QueryPoint(i + 1, Center_Point); Temp_Vertices.QueryPoint(i + 2, Last_Point); double angle = PRV_GetAngle(Center_Point, First_Point, Last_Point); if (angle < 30|| angle > 360 - 30)//这里设狭长角为30度 Temp_AllError.Add(Temp_EachFeature.OID.ToString()); } Temp_EachFeature = Temp_GetEachFeature.NextFeature(); } } System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Temp_GetEachFeature);//释放 }

计算角度的函数

//三个点计算角度        private double PRV_GetAngle(IPoint cen, IPoint first, IPoint second)        {            double ma_x = first.X - cen.X;            double ma_y = first.Y - cen.Y;            double mb_x = second.X - cen.X;            double mb_y = second.Y - cen.Y;            double v1 = (ma_x * mb_x) + (ma_y * mb_y);            double ma_val = Math.Sqrt(ma_x * ma_x + ma_y * ma_y);            double mb_val = Math.Sqrt(mb_x * mb_x + mb_y * mb_y);            double cosM = v1 / (ma_val * mb_val);            double angleAMB = Math.Acos(cosM) * 180 / System.Math.PI;            return angleAMB;        }

转载地址:http://hrqws.baihongyu.com/

你可能感兴趣的文章
设计模式15_模板
查看>>
海龟交易法则01_玩风险的交易者
查看>>
CTA策略02_boll
查看>>
vnpy通过jqdatasdk初始化实时数据及历史数据下载
查看>>
设计模式19_状态
查看>>
设计模式20_观察者
查看>>
vnpy学习10_常见坑
查看>>
vnpy学习10_常见坑02
查看>>
用时三个月,终于把所有的Python库全部整理了!拿去别客气!
查看>>
pd.stats.ols.MovingOLS以及替代
查看>>
vnpy学习11_增加测试评估指标
查看>>
资金流入流出计算方法
查看>>
海龟交易法则07_如何衡量风险
查看>>
海龟交易法则08_风险与资金管理
查看>>
海龟交易法则09_海龟式积木
查看>>
海龟交易法则10_通用积木
查看>>
海龟交易法则14_掌控心魔
查看>>
海龟交易法则15_万事俱备
查看>>
海龟交易法则16_附原版海龟交易法则
查看>>
克罗谈投资策略01_期货交易中的墨菲法则
查看>>