当前位置:网站首页>AutoCAD C polyline small acute angle detection
AutoCAD C polyline small acute angle detection
2022-06-28 06:03:00 【Wolfberry Angelica mutton soup】

#region Small acute angle detection
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();
// Traverse to obtain the vertex coordinates of the polyline
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)
{
// Calculate the penultimate angle
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);
}
// Calculate the last angle
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边栏推荐
- What is webrtc?
- easyui 重置多条件查询
- Data center: Seven Swords of data governance
- Global country (and region) information JSON data
- @Autowired注解为空的原因
- @The reason why the Autowired annotation is empty
- Example of MVVM framework based on kotlin+jetpack
- 猿粉猿动力-开发者活动袭!
- CSI以及本地盘的相关实现记录
- The custom cube UI pop-up dialog supports multiple and multiple types of input boxes
猜你喜欢

AutoCAD C# 多段线自相交检测

JSP

Xcode13.3.1 项目执行pod install后报错

Filecoin hacker song developer competition

Small ball playing

Sharing tips for efficient scripting

自定义 cube-ui 弹出框dialog支持多个且多种类型的input框

Binder interview: memory management unit

基于Kotlin+JetPack实现的MVVM框架的示例

【Paper Reading-3D Detection】Fully Convolutional One-Stage 3D Object Detection on LiDAR Range Images
随机推荐
idea创建类时自动添加注释
What is the e-commerce conversion rate so abstract?
Apple MDM Bypass 免越狱绕过MDM配置锁 免费
AutoCAD C# 多段线小锐角检测
bash install.sh ********错误
Sharing tips for efficient scripting
Development trend of mobile advertising: Leveraging stock and fine marketing
不会还有人只会用forEach遍历数组吧?
death_satan/hyperf-validate
YYGH-BUG-02
Mosaic data enhanced mosaic
全球国家(和地区)信息JSON数据
How popular are FB and WhatsApp mass messages in 2022?
Use of JDBC
Valueerror: iterative over raw text documents expected, string object received
mac下安装多个版本php并且进行管理
YYGH-7-用户管理
ipvs 导致syn 重传问题
开发者的时代红利在哪里?
【无标题】