当前位置:网站首页>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边栏推荐
- 原动力×云原生正发声 降本增效大讲堂
- ES9023音频解码芯片的工作原理
- Data middle office: an article that takes you to understand data middle office in simple terms
- What is webrtc?
- Mysql-17- create and manage tables
- Idea automatically adds comments when creating classes
- Difficulty calculation of Ethereum classic
- The length of pytorch dataloader the difference between epoch and iteration
- Valueerror: iterative over raw text documents expected, string object received
- Install fmpefg
猜你喜欢

Oracle fundamentals summary

Lenovo hybrid cloud Lenovo xcloud, new enterprise IT service portal

慢内容广告:品牌增长的长线主义

深度学习19种损失函数

socke.io長連接實現推送、版本控制、實時活躍用戶量統計

Binder interview: memory management unit
![A full set of excellent SEO tutorials worth 300 yuan [159 lessons]](/img/d7/7e522143b1e6b3acf14a0894f50d26.jpg)
A full set of excellent SEO tutorials worth 300 yuan [159 lessons]

高质量国产立体声编解码器CJC8988,Pin to Pin替代WM8988

socke.io长连接实现推送、版本控制、实时活跃用户量统计

联想混合云Lenovo xCloud,新企业IT服务门户
随机推荐
Simple handwritten debounce function
ThreadLocal
1404. 将二进制表示减到1的步骤数
YYGH-BUG-02
bash install.sh ********错误
5G网络整体架构
socke.io長連接實現推送、版本控制、實時活躍用戶量統計
Yygh-8-appointment registration
安装 Ffmpefg
重载,重写的区别,抽象类,接口的区别
@The reason why the Autowired annotation is empty
Ethereum Classic的难度计算|猿创征文
File foundation - read / write, storage
Enum
PKG package node project (express)
开发者的时代红利在哪里?
easyui 重置多条件查询
Small ball playing
使用pytorch和tensorflow计算分类模型的混淆矩阵
V4l2 driver layer analysis