当前位置:网站首页>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边栏推荐
- Use of JDBC
- Maskrcnn, fast RCNN, fast RCNN excellent video
- Global country (and region) information JSON data
- 深度学习19种损失函数
- Lombok @equalsandhashcode annotation how to make objects The equals () method compares only some attributes
- Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException:异常解决
- YYGH-BUG-02
- Qtcanpool q05: no border
- Oracle condition, circular statement
- 从0配置redis
猜你喜欢

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

Use of JDBC

Difficulty calculation of Ethereum classic

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

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

What is webrtc?

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

Lenovo hybrid cloud Lenovo xcloud, new enterprise IT service portal

Independent station sellers are using the five e-mail marketing skills, do you know?

YYGH-BUG-03
随机推荐
[MySQL] all query tables contain 20million data -- how to optimize SQL
预训练模型参数不匹配
Yygh-8-appointment registration
不会还有人只会用forEach遍历数组吧?
Differences between basic types and packaging classes
Independent station sellers are using the five e-mail marketing skills, do you know?
Capacity scheduling absolute value configuration queue usage and pit avoidance
脚本语言和编程语言
ipvs 导致syn 重传问题
Data warehouse: DWS layer design principle
Openharmony gnawing paper growth plan -- json-rpc
Main functions of 5ggnb and ng ENB
Binder interview: memory management unit
Failed to start component [StandardEngine[Catalina]. StandardHost[localhost]]
YYGH-7-用户管理
easyui 重置多条件查询
mac下安装多个版本php并且进行管理
Xcode13.3.1 error reported after pod install
若依实现下拉框
马赛克数据增强 mosaic