当前位置:网站首页>AutoCAD C# 多段线小锐角检测
AutoCAD C# 多段线小锐角检测
2022-06-28 06:02:00 【枸杞当归羊肉汤】

#region 小锐角检测
public static bool AcuteAngleDetect(Polyline pPolyline, double toloranceAngle, out List<Point3d> listPoint3Ds, out Exception error)
{
error = null;
listPoint3Ds = new List<Point3d>();
try
{
List<double> angles = new List<double>();
int vertexNum = pPolyline.NumberOfVertices;
Point3d pointFirst = new Point3d();
Point3d pointSecond = new Point3d();
// 遍历获取多段线顶点坐标
for (int i = 0; i < vertexNum-1; i++)
{
pointFirst = pPolyline.GetPoint3dAt(i);
pointSecond = pPolyline.GetPoint3dAt(i + 1);
double angle = GetAngleByTwoPoint(pointFirst, pointSecond);
if (i>0)
{
double preAngle = angles[i-1];
if (DetectAcuteAngleUsingVectorAngle(toloranceAngle, preAngle, angle))
{
listPoint3Ds.Add(pointFirst);
}
}
angles.Add(angle);
}
if (pPolyline.Closed)
{
// 计算倒数第二个角
pointFirst = pPolyline.GetPoint3dAt(vertexNum - 1);
pointSecond = pPolyline.GetPoint3dAt(0);
double angle = GetAngleByTwoPoint(pointFirst, pointSecond);
double preAngle = angles[angles.Count-1];
if (DetectAcuteAngleUsingVectorAngle(toloranceAngle, preAngle, angle))
{
listPoint3Ds.Add(pointFirst);
}
// 计算最后一个角
angle = angles[angles.Count - 1];
preAngle = angles[0];
if (DetectAcuteAngleUsingVectorAngle(toloranceAngle, preAngle, angle))
{
listPoint3Ds.Add(pPolyline.GetPoint3dAt(0));
}
}
return true;
}
catch (Exception ex)
{
error = ex;
return false;
}
}
public static double GetAngleByTwoPoint(Point3d first, Point3d second)
{
return Math.Atan2(second.Y - first.Y, second.X - first.X) * 180 / Math.PI;
}
public static bool DetectAcuteAngleUsingVectorAngle(double toloranceAngle, double angleFirst, double angleSecond)
{
return Math.Abs(Math.Abs(angleSecond - angleFirst) - 180) < toloranceAngle;
}
#endregion边栏推荐
- ThreadLocal
- 全球国家(和地区)信息JSON数据
- 阿里云短信服务(完整指南),短信发送功能实现。
- 脚本语言和编程语言
- 联想混合云Lenovo xCloud,新企业IT服务门户
- Data middle office: six questions data middle office
- The windows environment redis uses AOF persistence and cannot generate an AOF file. After generation, the content of the AOF file cannot be loaded
- @The reason why the Autowired annotation is empty
- Oracle condition, circular statement
- Simple handwritten debounce function
猜你喜欢

How popular are FB and WhatsApp mass messages in 2022?

Oracle fundamentals summary

YYGH-8-预约挂号

Yygh-6-wechat login

Socket. Io long Connection Push, version Control, Real - Time Active user volume Statistics

Sklearn Feature Engineering (summary)

What are the advantages of e-mail marketing? Why do sellers of shopline independent station attach so much importance to it?

Filecoin hacker song developer competition

若依实现下拉框

开发者的时代红利在哪里?
随机推荐
自定义 cube-ui 弹出框dialog支持多个且多种类型的input框
什么是WebRTC?
Ethereum Classic的难度计算|猿创征文
lombok @EqualsAndHashCode 注解如何让对象.equals()方法只比较部分属性
pytorch dataloader的长度 epoch与iteration的区别
Yygh-6-wechat login
联想混合云Lenovo xCloud,新企业IT服务门户
Yygh-8-appointment registration
基于Kotlin+JetPack实现的MVVM框架的示例
MR-WordCount
MySQL common functions
Data middle office: construction ideas and implementation experience of data governance
ThreadLocal
Deep learning 19 loss functions
Filecoin hacker song developer competition
6. 毕业设计温湿度监控系统(ESP8266 + DHT11 +OLED 实时上传温湿度数据给公网服务器并在OLED显示屏上显示实时温湿度)
CSI以及本地盘的相关实现记录
bash install. SH ******** error
使用pytorch和tensorflow计算分类模型的混淆矩阵
Failed to start component [StandardEngine[Catalina]. StandardHost[localhost]]