AutoCAD中凸度的概念以及求圆弧的凸度

转自http://blog.163.com/wslngcjsdxdr@126/blog/static/162196230201241624451397/

The bulge factor is used to indicate how much of an arc segment is present at this vertex. The bulge factor is the tangent of one fourth the included angle for an arc segment, made negative if the arc goes clockwise from the start point to the endpoint. A bulge of 0 indicates a straight segment, and a bulge of 1 is a semicircle.

凸度被用来表示一个顶点的弧度大小,它的值是这段弧所包含角度的1/4角度的正切。如果弧从起点到终点是顺时针走向则凸度为负数,0表示直线,1表示半圆。


 

在将圆弧转化为多段线(AcDbPolyLine)时,需要计算圆弧的凸度。在AutoCAD中规定,圆弧的走向始终是逆时针走向,所以终点角度应大小起点角度(以圆心为原点中,以X轴正方向为0,逆时针旋转为正角)。当终点角度小于起点角度时,应加上2π(下图中的图3和图4)这样得到的凸度值表示逆时针走向的凸度,当需要表示顺时针方面的弧度时,需要在这个值前面加负号。

下图中,图1,图2的绘制方向相反,但起点(小圆表示)到终点(小三角形表示)的走向是一样的。同理图3和图4也是一样但在计算凸度时终点角度小于起点角度,应加上2π。


 

 



 
 


以下是其算法(注意得到的值是逆时针走向的凸度)

double GetBulge(AcDbArc*& pArc)

{

double dStartAngle = pArc->startAngle();

double dEndAngle = pArc->endAngle();

double dAlfa = dEndAngle - dStartAngle;

if (dAlfa < 0.0)//如果终点角度小于起点角度

{

dAlfa = 2 * PI + dAlfa;

}

double dBulge = 0.0;

dBulge = tan((dAlfa) / 4.0);

return dBulge;

}

 


  • 5
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要修改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(); } ``` 这段代码首先提示用户选择多段线以及要修改的段,然后计算新的凸度值对应的圆弧属性,最后修改凸度值并更新多段线的属性和视图。请注意,这段代码未经过完整测试,实际使用时可能需要进行调整和优化。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值