天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 6|回复: 0

三点画弧

[复制链接]
  • TA的每日心情
    开心
    昨天 15:23
  • 签到天数: 69 天

    [LV.6]常住居民II

    410

    主题

    167

    回帖

    2704

    积分

    管理员

    积分
    2704
    发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
    AcGePoint2d pt1 pt2 pt3;
    AcGePoint2d center.

    Lets find the center point of the Arc:

    double yDeltaA = pt2.y - pt1.y;

    double xDeltaA = pt2.x - pt1.x;

    double yDeltaB = pt3.y - pt2.y;

    double xDeltaB = pt3.x - pt2.x;

    //case for vertical or horizontal

    if (fabs(xDeltaA) <= fuzz && fabs(yDeltaB) <= fuzz){

    center.x = (pt2.x + pt3.x)/2.0;

    center.y = (pt1.y + pt2.y)/2.0;

    } else {

    double aSlope=yDeltaA/xDeltaA;

    double bSlope=yDeltaB/xDeltaB;

    // checking whether the given points are colinear.

    if (fabs(aSlope-bSlope) <= fuzz) return false;

    center.x = (aSlope*bSlope*(pt1.y - pt3.y) + bSlope*(pt1.x + pt2.x)

    - aSlope*(pt2.x+pt3.x))/(2* (bSlope-aSlope));

    center.y = -1*(center.x - (pt1.x+pt2.x)/2.0)/aSlope+(pt1.y+pt2.y)/2.0;

    }

    Now to calculate the bulge we need the included angle.
    The bulge is calculates as tan(includedAngle/4.0);

    So get the Angles:
    double startang = acutAngle(asPtn2d(center), asPtn2d(pt1));

    double endang = acutAngle(asPtn2d(center), asPtn2d(pt3));

    We now need to know the clock but there are 2 posibilities!
    Your function is fine here but change it to accept to a AcGePoint2d

    clock1 = cwisept (pt1, pt2, pt3);
    clock2 = cwisept (pt1, center, pt3);

    The diff_angle function normalises the angle
    if (clock1 == clock2) {

    includedAngle = 2.0*_PI-diff_angle(startang, endang);

    } else {

    includedAngle = diff_angle(endang, startang);

    }

    double bulge = tan(includedAngle/4.0);

    That it!

    So to make it!
    AcDbPolyline *plx = new AcDbPolyline;

    plx->addVertexAt(0, pt1, bulge);

    plx->addVertexAt(1, pt3, 0.0);

    now Append the entity to the database and you are done!



    Regards Gary.

    [url]www.drcauto.com[/url]

    #define ANG360 (2.0*_PI)

    double diff_angle(double a1x, double a2x )

    {

    double delta;

    double a1, a2;

    a1 = fmod(a1x, ANG360);

    a2 = fmod(a2x, ANG360);

    if(fabs(a1) > _PI ) {

    if( a1 < 0.0 )

    a1 += ANG360;

    else

    a1 -= ANG360;

    }

    if (fabs(a2) > _PI) {

    if( a2 < 0.0 )

    a2 += ANG360;

    else

    a2 -= ANG360;

    }

    delta = a1 - a2;

    if(delta > ANG360) {

    delta = fmod(delta, ANG360);

    }

    if(fabs(delta) > _PI) {

    if(delta < 0.0 )

    delta += ANG360;

    else

    delta -= ANG360;

    }

    return delta;

    }

     

     

     

     

    三点画弧
    中国膜结构网打造全中国最好的膜结构综合平台 ,统一协调膜结构设计,膜结构施工,膜材采购,膜材定制,膜结构预算全方位服务。 中国空间膜结构协会合作单位。
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|

    GMT+8, 2024-7-1 05:34 , Processed in 0.058606 second(s), 22 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

    快速回复 返回顶部 返回列表