当前位置:网站首页>AutoCAD C# 多段線小銳角檢測
AutoCAD C# 多段線小銳角檢測
2022-06-28 06:03: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
边栏推荐
- Apple MDM bypass jailfree bypass MDM configuration lock free
- Scripting and programming languages
- Install fmpefg
- Simple handwritten debounce function
- At first glance, I can see several methods used by motionlayout
- Alibaba cloud SMS service (Complete Guide), SMS sending function implementation.
- 开发者的时代红利在哪里?
- Data center: Seven Swords of data governance
- Maskrcnn,fast rcnn, faster rcnn优秀视频
- pytorch dataloader的长度 epoch与iteration的区别
猜你喜欢
若依实现下拉框
socke. IO long connection enables push, version control, and real-time active user statistics
A full set of excellent SEO tutorials worth 300 yuan [159 lessons]
Socket. Io long Connection Push, version Control, Real - Time Active user volume Statistics
Apple MDM bypass jailfree bypass MDM configuration lock free
Yygh-8-appointment registration
socke.io長連接實現推送、版本控制、實時活躍用戶量統計
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance
Install and manage multiple versions of PHP under mac
容量调度绝对值配置队列使用与避坑
随机推荐
lombok @EqualsAndHashCode 注解如何让对象.equals()方法只比较部分属性
Introduction to openscap
Introduction to uicollectionviewdiffabledatasource and nsdiffabledatasourcesnapshot
Ape pink ape power - Developer activity attack!
bash install.sh ********错误
简单手写debounce函数
6. graduation design temperature and humidity monitoring system (esp8266 + DHT11 +oled real-time upload temperature and humidity data to the public network server and display the real-time temperature
MR-WordCount
idea根据数据库表生成实体类
SQL and list de duplication
使用SSM框架,配置多个数据库连接
JSP
Development trend of mobile advertising: Leveraging stock and fine marketing
Yolact++ Pytorch环境
Important basis for ERP software company selection
Deep learning 19 loss functions
Where is the era bonus for developers?
借助nz-pagination中的let-total解析ng-template
Install redis on windows and permanently change the password, and integrate redis with the SSM framework
Data warehouse: DWS layer design principle