天气与日历 切换到窄版

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

椭圆

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

    [LV.4]偶尔看看III

    105

    主题

    11

    回帖

    1308

    积分

    管理员

    积分
    1308
    QQ
    发表于 2024-3-6 11:48:43 | 显示全部楼层 |阅读模式
    1. cDbObjectId FymEllipse::Add(const AcGePoint3d& ptCenter, const AcGeVector3d& vecNormal, const AcGeVector3d& majorAxis, double ratio)
    2. {//缺省的两个参数为椭圆起始弧度与终止弧度,ratio为大半径与小半径比
    3.         AcDbEllipse* pEllipse = new AcDbEllipse(ptCenter, vecNormal, majorAxis, ratio);
    4.         return FymDatabase::PostToModelSpace(pEllipse);
    5. }
    6. AcDbObjectId FymEllipse::Add(const AcGePoint2d& pt1, const AcGePoint2d& pt2) {
    7.         AcGePoint3d ptCenter;
    8.         ptCenter = FymGeometry::GetMiddlePt(FymConverUtil::ToPoint3d(pt1), FymConverUtil::ToPoint3d(pt2));
    9.         AcGeVector3d vecNormal(0, 0, 1);
    10.         AcGeVector3d majorAxis(fabs(pt1.x - pt2.x) / 2, 0, 0);
    11.         double ratio = fabs((pt1.y - pt2.y) / (pt1.x - pt2.x));
    12.         return Add(ptCenter, vecNormal, majorAxis, ratio);
    13. }
    14. AcDbObjectId FymEllipse::Add(const AcGePoint2d& pt1, const AcGePoint2d& pt2, const AcGePoint2d& pt3)
    15. {
    16.         AcGePoint3d ptCenter;
    17.         ptCenter = FymGeometry::GetMiddlePt(FymConverUtil::ToPoint3d(pt1), FymConverUtil::ToPoint3d(pt2));
    18.         AcGeVector3d vecNormal(0, 0, 1);
    19.         double ellipseAsq = pow(pt1.x - ptCenter.x, 2) + pow(pt1.y - ptCenter.y, 2);
    20.         double ellipseBsq = pow(pt3.x - ptCenter.x, 2) + pow(pt3.y - ptCenter.y, 2);
    21.         AcGeVector3d majorAxis;
    22.         double ratio;
    23.         if (ellipseAsq > ellipseBsq)
    24.         {
    25.                 majorAxis = AcGeVector3d((ptCenter.x - pt1.x), (ptCenter.y - pt1.y), 0.0);
    26.                 ratio = sqrt(ellipseBsq/ellipseAsq);
    27.         }
    28.         else
    29.         {
    30.                 majorAxis = AcGeVector3d((ptCenter.x - pt3.x), (ptCenter.y - pt3.y), 0.0);
    31.                 ratio = sqrt(ellipseAsq/ellipseBsq);
    32.         }
    33.         return Add(ptCenter, vecNormal, majorAxis, ratio);
    34. }
    复制代码

     

     

     

     

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

    本版积分规则

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

    GMT+8, 2024-11-1 09:32 , Processed in 0.168703 second(s), 27 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

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