当前位置:网站首页>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边栏推荐
猜你喜欢

At first glance, I can see several methods used by motionlayout

上海域格ASR CAT1 4g模块2路保活低功耗4G应用
![RL practice (0) - and the platform xinchou winter season [rule based policy]](/img/dc/10d615c64123475fea180e035095ff.png)
RL practice (0) - and the platform xinchou winter season [rule based policy]

Prime mover × Cloud primordial is making sound, reducing cost and increasing efficiency lecture hall

Oracle condition, circular statement

联想混合云Lenovo xCloud,新企业IT服务门户

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

Binder interview: memory management unit

Working principle of es9023 audio decoding chip

Apple MDM bypass jailfree bypass MDM configuration lock free
随机推荐
Select trigger event from easyUI drop-down box
windows上安装redis并永久修改密码,及ssm框架集成redis
【MYSQL】所有查询表中有2千万数据--sql如何优化
Small ball playing
mysql常用函数
马赛克数据增强 mosaic
上海域格ASR CAT1 4g模块2路保活低功耗4G应用
Openharmony gnawing paper growth plan -- json-rpc
高质量国产立体声编解码器CJC8988,Pin to Pin替代WM8988
Data middle office: an article that takes you to understand data middle office in simple terms
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance
Yygh-6-wechat login
Scripting and programming languages
Global country (and region) information JSON data
阿里云短信服务(完整指南),短信发送功能实现。
Mysql-16-subquery
安装 Ffmpefg
Enum
2022年全国职业院校技能大赛“网络安全”竞赛试题官方答案
Deep learning 19 loss functions