"凸度"——CAD多段线中的弧定义

“凸度”——CAD,多段线中的弧定义,ployline

##两种表示转换
在这里插入图片描述

" 凸 度 " = tan ⁡ ( α 4 ) = h s "凸度"= \tan(\frac{\alpha}{4})=\frac{h}{s} ""=tan(4α)=sh

弧从起点到终点是顺时针走向则凸度为负数
"凸度"表示
(10 x y z);起点
(42 "凸度,负号为逆时针")


圆心角表示
(10 x y z);圆心坐标
(40 r);半径
(50 deg);起点弧度
(51 deg);端点弧度
(73 0);1逆,0顺时针标志

R = h 2 + s 2 2 h R=\frac {h^2+s^2}{2h} R=2hh2+s2

h 与 r 的关系决定弧为圆上的大弧还是小弧

if s > r:为大弧

if s<r:为小弧

在这里插入图片描述

β = ( 9 0 o − a r c t a n ( h s ) ∗ 2 )   m o d   9 0 o β=(90^o-arctan(\frac{h}{s})*2)\space mod\space 90^o β=(90oarctan(sh)2) mod 90o

求圆心,利用向量旋转计算公式

逆时针:
 x=xcos(β)-ysin(β);
 y=ycos(β)+xsin(β);

顺时针:
  x=xcos(β)+ysin(β);
  y=ycos(β)-xsin(β);

λ = r A B λ=\frac{r}{AB} λ=ABr
A C ⃗ = λ A B ⃗ \vec{AC} = λ \vec {AB} AC =λAB

O x = C x c o s ( β ) + C y s i n ( β ) ; O_x=C_xcos(β)+C_ysin(β); Ox=Cxcos(β)+Cysin(β);
O y = C y c o s ( β ) − C x s i n ( β ) ; O_y=C_ycos(β)-C_xsin(β); Oy=Cycos(β)Cxsin(β);

对弧的打断

在这里插入图片描述

已知A点,B点,半径R与弧的凸度。 C’ 是已知弧附近的一点,找到弧上对应点C对弧进行分割

O C ′ O C O C ′ ⃗ = O C ⃗ \frac{OC'}{OC} \vec {OC'} = \vec{OC} OCOCOC =OC
F = C + B 2 F=\frac {C+B}{2} F=2C+B
C B 凸 度 = 2 ∗ ( R − O F ) C B CB_{凸度} = \frac{2*(R-OF)}{CB} CB=CB2(ROF)

要修改CAD多段线某一段凸度,您可以使用以下C#代码: ```csharp using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Geometry; using Autodesk.AutoCAD.Runtime; public void ModifyPolylineArcBulge() { // 获取当前文档和数据库 Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; // 提示用户选择多段线 PromptEntityOptions peo = new PromptEntityOptions("\n请选择多段线:"); peo.SetRejectMessage("\n请选择有效的多段线。"); peo.AddAllowedClass(typeof(Polyline), true); PromptEntityResult per = doc.Editor.GetEntity(peo); if (per.Status != PromptStatus.OK) return; // 获取多段线对象 Polyline polyline = (Polyline)per.ObjectId.GetObject(OpenMode.ForWrite); // 提示用户选择要修改的段 PromptIntegerOptions pio = new PromptIntegerOptions("\n请选择要修改的段:"); pio.AllowZero = false; pio.AllowNegative = false; pio.LowerLimit = 1; pio.UpperLimit = polyline.NumberOfVertices - 1; PromptIntegerResult pir = doc.Editor.GetInteger(pio); if (pir.Status != PromptStatus.OK) return; // 获取段的起点和终点 Point3d start = polyline.GetPoint3dAt(pir.Value - 1); Point3d end = polyline.GetPoint3dAt(pir.Value); // 计算段的点 Point3d midpoint = start + ((end - start) / 2.0); // 提示用户输入新的凸度值 PromptDoubleOptions pdo = new PromptDoubleOptions("\n请输入新的凸度值:"); pdo.AllowZero = false; pdo.AllowNegative = false; PromptDoubleResult pdr = doc.Editor.GetDouble(pdo); if (pdr.Status != PromptStatus.OK) return; // 计算新的弦长和半径 double chordLength = start.DistanceTo(end); double radius = (chordLength / 2.0) / Math.Abs(pdr.Value); // 计算新的圆心和起始角度和终止角度 Vector3d direction = end - start; double angle = direction.AngleOnPlane(Vector3d.ZAxis); if (direction.Y < 0) angle = 2 * Math.PI - angle; Point3d center = midpoint + (Vector3d.ZAxis * radius * Math.Sign(pdr.Value)); double startAngle = (start - center).AngleOnPlane(Vector3d.ZAxis); double endAngle = (end - center).AngleOnPlane(Vector3d.ZAxis); if (Math.Abs(pdr.Value) < 0.0001) endAngle = startAngle + Math.PI; // 修改凸度值 polyline.SetBulgeAt(pir.Value - 1, Math.Tan(angle / 4.0) * Math.Sign(pdr.Value)); // 修改的属性 Arc arc = new Arc(center, radius, startAngle, endAngle); polyline.SetArcSegmentAt(pir.Value - 1, arc); polyline.Closed = false; // 更新视图 doc.Editor.UpdateScreen(); } ``` 这段代码首先提示用户选择多段线以及要修改的段,然后计算新的凸度值对应的圆属性,最后修改凸度值并更新多段线的属性和视图。请注意,这段代码未经过完整测试,实际使用时可能需要进行调整和优化。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值