天气与日历 切换到窄版

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

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

    [LV.4]偶尔看看III

    105

    主题

    11

    回帖

    1308

    积分

    管理员

    积分
    1308
    QQ
    发表于 2024-3-6 11:48:55 | 显示全部楼层 |阅读模式
    1. AcDbObjectId FymCircle::Add(const AcGePoint3d& centerPt, const AcGeVector3d& normal, double radius)
    2. {
    3.         AcDbCircle* pcir = new AcDbCircle(centerPt, normal, radius);
    4.         return FymDatabase::PostToModelSpace(pcir);
    5. }
    6. AcDbObjectId FymCircle::Add(const AcGePoint3d& centerPt, double radius)
    7. {
    8.         AcGeVector3d vec(0, 0, 1);//默认normal
    9.         return Add(centerPt, vec, radius);
    10. }
    11. AcDbObjectId FymCircle::Add(const AcGePoint2d& point1, const AcGePoint2d& point2)//点在圆上
    12. {
    13.         AcGePoint2d center = FymGeometry::GetMiddlePt(point1, point2);
    14.         AcGePoint3d center3d(center.x, center.y, 0.0);
    15.         double radius = center.distanceTo(point1);//中点和点1距离
    16.         return Add(center3d, radius);
    17. }
    18. AcDbObjectId FymCircle::AddByMath(const AcGePoint2d& point1, const AcGePoint2d& point2, const AcGePoint2d& point3)
    19. {
    20.         double xysm = 0, xyse = 0, xy = 0;
    21.         AcGePoint3d ptCenter;
    22.         double radius = 0;
    23.         //sqrt为求平方根函数
    24.         xy = pow(point1.x, 2) + pow(point2.y, 2);
    25.         xyse = xy - pow(point3.x, 2) - pow(point3.y, 2);
    26.         xysm = xy - pow(point2.x, 2) - pow(point2.y, 2);
    27.         xy = (point1.x - point2.x) * (point1.y - point3.y) - (point1.x - point3.x) * (point1.y - point2.y);
    28.         //fabs为绝对值函数
    29.         if (fabs(xy) < 0.000001)
    30.         {
    31.                 AfxMessageBox(采用T("输入参数无效,不能创建图形!"));
    32.                 return AcDbObjectId::kNull;
    33.         }
    34.         ptCenter.x = (xysm * (point1.y - point3.y) - xyse * (point1.y - point2.y)) / (2 * xy);
    35.         ptCenter.y = (xysm * (point1.x - point2.x) - xysm * (point1.x - point3.x)) / (2 * xy);
    36.         ptCenter.z = 0.0;
    37.         //sqrt为求平方根函数
    38.         radius = sqrt((point1.x - ptCenter.x) * (point1.x - ptCenter.x) + (point1.y - ptCenter.y) * (point1.y - ptCenter.y));
    39.         if (radius < 0.0000001)
    40.         {
    41.                 AfxMessageBox(采用T("半径过小!"));//在CAD界面弹出消息框
    42.                 return AcDbObjectId::kNull;
    43.         }
    44.         return Add(ptCenter, radius);
    45. }
    46. AcDbObjectId FymCircle::Add(const AcGePoint2d& point1, const AcGePoint2d& point2, const AcGePoint2d& point3)
    47. {
    48.         AcGeCircArc2d geArc(point1, point2, point3);
    49.         AcGePoint3d center(geArc.center().x, geArc.center().y, 0.0);
    50.         return Add(center, geArc.radius());
    51. }
    复制代码

     

     

     

     

    圆
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

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

    GMT+8, 2024-11-1 09:19 , Processed in 0.124725 second(s), 29 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

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